theme-language-server: creating or deleting a folder leaves stale readDirectory/stat cache
Maintainers usually reply within 2 days
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 68/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- typescript
- Domain
- devtools
Research direction
Start in startServer and trace how watched-file create, delete, and rename events invalidate readDirectory, stat, and readFile caches. Check how paths are represented and where the workspace root is determined before changing invalidation. Done when creating or deleting nested folders, and renaming files across folders, refresh directory listings and stats without restarting the server.
Written by the indexing model from the issue text.
Description
Hi! When a watched-file event creates or deletes a file, startServer only invalidates readDirectory for that file's own folder (path.dirname(change.uri)), plus readFile and stat for the file itself.
That's not enough when the event creates or removes a whole folder. Say a theme has no snippets/ folder yet, and then snippets/card.liquid is created. readDirectory of the theme root and stat of snippets/ are still cached from before, so the server keeps thinking snippets/ doesn't exist. Snippet completion stays empty until you restart the server. The same happens the other way round when the last file in a folder is deleted: the cached root listing still has the folder, and walking it fails.
What fixed it for us was invalidating readDirectory and stat for every folder above the created or deleted file, up to the root, not just its direct parent. Renames have the same problem, since they also only invalidate the two parent folders.
We hit this on 2.21.2, and main looks the same. Happy to send a PR.
- 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: checks get dropped while a forced runChecks is pendingPossibly taken @efegokdemir claimed this 11 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 76/100
Shopify/theme-tools#1385 · 1 comment ·
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