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

Offen
#21 3 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 2 Tagen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
45/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Veraltet
Tech-Stack
typescript

Rechercherichtung

Beginne mit der setup-Methode von theme-docs-updater und untersuche deren Aufrufe von latestRevision und download. Reproduziere den Start bei nicht verfügbarem Wi-Fi und überprüfe anschließend, dass der Vorgang nach spätestens dem angeforderten Timeout mit der auf der Festplatte vorhandenen Dokumentation fortgesetzt wird, anstatt hängen zu bleiben.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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...
    }
  });

Vorherrschende Sprache
TypeScript
Sterne
245
Forks
108
Ø Merge
2 T. 8 Std.
Gemergte PRs (30 T.)
24

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus Shopify/theme-tools

Alle Issues in Shopify/theme-tools

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.