Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Tons of errors are ignored

Aperta
#2,852 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
react-native, typescript
Ambito
cli

Direzione di ricerca

Inizia da isPackagerRunning.ts e segui ogni try/catch annidato intorno a fetch, ai dati della risposta e agli header. Confronta i casi segnalati di dati undefined e di errori imprevisti con gli esiti previsti running, not_running e unrecognized. Il lavoro è completo quando gli errori non vengono più ignorati silenziosamente o interpretati in modo errato e il comportamento viene reso visibile dove lo richiede l’issue.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Hello. This bug is to keep track of a multitude of small issues where errors are silently ignored or misinterpreted. There are several pull requests fixing some of them already but this one does not appear to have a PR yet and is a great example. From isPackagerRunning.ts:

async function isPackagerRunning(
  packagerPort: string | number = process.env.RCT_METRO_PORT || '8081',
): Promise<
  | {
      status: 'running';
      root: string;
    }
  | 'not_running'
  | 'unrecognized'
> {
  try {
    const {data, headers} = await fetch(
      `http://localhost:${packagerPort}/status`,
    );

    try {
      if (data === 'packager-status:running') {
        return {
          status: 'running',
          root: headers.get('X-React-Native-Project-Root') ?? '',
        };
      }
    } catch (_error) {
      return 'unrecognized';
    }
    return 'unrecognized';
  } catch (_error) {
    return 'not_running';
  }
}

Two issues here had me chasing false starts with another bug:

  • Any error interpreting the data (e.g. data is undefined) is treated as undefined. This will likely be wrong so at minimum there should be a visible by default warning in this scenario
  • Any issue during this entire process that isn't explicitly handles is treated as not_running. Again this might be ok if the unrecognized error were visible, since that will not always be the correct thing to do

Bit of a side note with this snippet, there is a lot of unnecessary complexity that stems from the strange shape of this methods return type. We might want to make it something like

{status: 'running' | 'not_running' | 'unrecognized', root: string?} 

and/or use an enum for the status. This is just "bug prone" not itself a bug, and we would need to refractor this area anyway, so let me know if we feel like this should be its own bug or if we should ignore it.

Lingua principale
TypeScript
Stelle
2.9k
Fork
948
Merge medio
10g 19h
PR unite (30g)
1

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di react-native-community/cli

Tutte le issue di react-native-community/cli

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.