docs-updater should race against a timeout or else starting the language server hangs.

Aperta
#21 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
typescript

Direzione di ricerca

Inizia dal metodo setup di theme-docs-updater e ispeziona le chiamate a latestRevision e download. Riproduci l’avvio con il Wi-Fi non disponibile, quindi verifica che proceda usando la documentazione su disco dopo al massimo il timeout richiesto, invece di rimanere bloccato.

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

Descrizione

tech debt

Describe the bug
The VS Code extension hangs if you start it with Wifi down (happened to me during storms last week). It hangs because theme-docs-updater attempts to download latest.json from theme-liquid-docs and it doesn't timeout (or the timeout is long).

We should do something more along the lines of "wait at most 5s and otherwise go with what is on disk".

Something like this:

const timeout = (ms: number) => new Promise((_, reject) => setTimeout(reject, ms));

  /**
   * The setup method checks that the latest revision matches the one from
   * Shopify/theme-liquid-docs. If there's a diff in revision, it means
   * that the documentations that you have locally are out of date.
   *
   * The setup method then downloads the other files.
   */
  setup = memo(async (): Promise<void> => {
    if (!(await exists(root))) {
      await fs.mkdir(root, { recursive: true });
    }

    const local = await this.latestRevision();
    try {
      await Promise.race([download('latest'), timeout(2000)]);
      const remote = await this.latestRevision();
      if (local !== remote) {
        await Promise.all(Resources.map((resource) => download(resource)));
      }
    } catch (_) {
      // we're offline...
    }
  });

Lingua principale
TypeScript
Stelle
245
Fork
108
Merge medio
2g 8h
PR unite (30g)
24

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 Shopify/theme-tools

Tutte le issue di Shopify/theme-tools

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.