docs-updater should race against a timeout or else starting the language server hangs.
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 234
- Forks
- 92
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 6
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...
}
});
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the theme-docs-updater setup method and inspect its latestRevision and download calls. Reproduce startup with Wi-Fi unavailable, then verify that it proceeds using on-disk documentation after at most the requested timeout instead of hanging.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- developer-experience, devtools
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100