Shopify / theme-tools

Everything developer experience for Shopify themes
https://shopify.dev/docs/themes
MIT License
63 stars 19 forks source link

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

Open charlespwd opened 1 year ago

charlespwd commented 1 year ago

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...
    }
  });
services-db[bot] commented 1 year ago

You have created a Bug without a Severity label of the format SEV-X.

It is important for Bugs to be correctly labeled and categorized so we have better visibility over our development health practices and make sure we are prioritizing the right investments.

The untriaged label has been added. Please remove it once the team has set the correct severity for this bug.

Learn more in this Vault Page.

charlespwd commented 11 months ago

Terribly low value. You need to lose wifi connection between downloading the extension and then using it.

I'm going to assume that since you were able to download the extension, you are able to download the docs.