-
Notifications
You must be signed in to change notification settings - Fork 64
Open
Labels
Description
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...
}
});