theme-language-server: checks get dropped while a forced runChecks is pending
Maintainers usually reply within 2 days
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 76/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript
- Domain
- devtools
Research direction
Start with src/utils/debounce.ts and trace how runChecks passes trigger URIs through normal and forced calls. Check the debounce tests and the language server call sites to see how multiple roots are handled. Done means pending checks are retained across calls and diagnostics arrive for every affected file; add or update tests for the reported timing cases.
Written by the indexing model from the issue text.
Description
Hi! We run our own language server on top of startServer from @shopify/theme-language-server-common, and we noticed that sometimes an open file just never gets diagnostics until you edit it again.
I tracked it down to debounce in src/utils/debounce.ts. Once runChecks.force(...) has been called, every other call is ignored until that forced run has finished (if (timeoutId !== null && force) return;). And since only the arguments of the last call are kept, a normal call made within 100 ms of another one also replaces it.
So you can lose a check in a few ways:
- A file is opened while a forced run is waiting or running (for example right after a watched file changed). If the forced run already read its theme, that new file isn't in it, and its own request was ignored. No diagnostics.
- Two files from two different themes (two roots in the workspace) are opened within 100 ms. Only the second one gets checked.
- A forced call replaces a normal call that was still waiting.
It's easy to hit when the editor restores several tabs at startup while something on disk is changing.
What fixed it for us was keeping a set of all the trigger URIs from every call, forced or not, and passing all of them to the next run, instead of keeping only the last call. Happy to open a PR if that sounds like the right direction.
We reproduced it on 2.21.2, and the code on main looks the same.
- Dominant language
- TypeScript
- Stars
- 245
- Forks
- 108
- Avg merge
- 2d 8h
- Merged PRs (30d)
- 24
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing 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.
More from Shopify/theme-tools
-
ThemeCheck incorrectly reports error when `with` is used in snippetPossibly taken @efegokdemir claimed this 3 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Shopify/theme-tools#1408 ·
Maintainers usually reply within 2 days
-
CdnPreconnect misses `href="https://cdn.shopify.com"` without a trailing pathPossibly taken @RaphaelFakhri claimed this 32 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Shopify/theme-tools#1365 ·
Maintainers usually reply within 2 days
-
theme-graph CLI never calls getWebComponentMap, so custom-element references are never resolvedPossibly taken @reginaldalfret claimed this 50 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Shopify/theme-tools#1291 · 1 comment ·
Maintainers usually reply within 2 days
-
JSONMissingBlock false positive for app block when section supports both @app and @themeMay be free again A pull request for this issue was closed without being merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Shopify/theme-tools#1144 · 2 comments · 8 reactions ·
Maintainers usually reply within 2 days
-
theme-language-server: creating or deleting a folder leaves stale readDirectory/stat cachePossibly taken @efegokdemir claimed this 13 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 68/100
Shopify/theme-tools#1386 ·
Maintainers usually reply within 2 days
All issues in Shopify/theme-tools
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 66/100
-
Difficulty 1/5 Under an hour Newbie friendliness 65/100
prometheus/docs#3198 ·
Maintainers usually reply within 3 days
-
[Bug]: OpenCode v2 skips an assistant message that gains text after an earlier capturePossibly taken @jianyx1 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
volcengine/OpenViking#8354 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
ARTPARK-SAHAI-ORG/calibrate-frontend#842 ·
Maintainers usually reply within 1 day
-
Chat: Copying a selection that includes the end of a message also copies the actions menu labelsOpen
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
suitenumerique/hub#176 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day