Read only theme directories and their direct children when preloading files#1157
Open
elia wants to merge 1 commit intoShopify:mainfrom
Open
Read only theme directories and their direct children when preloading files#1157elia wants to merge 1 commit intoShopify:mainfrom
elia wants to merge 1 commit intoShopify:mainfrom
Conversation
1 task
aswamy
approved these changes
Mar 23, 2026
Contributor
aswamy
left a comment
There was a problem hiding this comment.
I suggested one minor change, but looks great!
packages/theme-language-server-common/src/documents/DocumentManager.ts
Outdated
Show resolved
Hide resolved
Restrict preload() to Shopify theme directories (assets, blocks, config, layout, locales, sections, snippets, templates). Previously all .json files under the root were loaded, including unrelated data files. A single 175 MB JSON file parsed into an AST can consume 1-2 GB of heap, easily exhausting even an 8 GB limit on large repos. Co-Authored-By: Claude <noreply@anthropic.com>
Author
Done ✅ |
graygilmore
reviewed
Mar 23, 2026
Contributor
There was a problem hiding this comment.
The test failures look real:
- "uri": "mock-fs:/templates/index.json",
+ "uri": "mock-fs:sections/header.json",I'm not sure what's going on there.
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What are you adding in this PR?
Fixes #1151, this is an alternative to #1152, after having another look at the problem following @aswamy's comment.
When preloading files at startup, the language server was recursively loading all
.jsonfiles under the theme root — including unrelated data files (e.g.data/orders.json). A single 175 MB JSON file parsed into an AST can consume 1–2 GB of heap, easily exhausting even an 8 GB limit on repos that happen to have adata/directory alongside the theme.This change restricts preloading to Shopify theme directories only:
assets,blocks,config,layout,locales,sections,snippets,templates,templates/customers, andtemplates/metaobjects. It will only read the direct children of these directories, not their subdirectories, which is consistent with the theme architecture specification and should be sufficient for language features.What's next? Any followup issues?
None.
What did you learn?
Nothing surprising in retrospect, but worth noting:
recursiveReadDirectorystarts from the workspace root, not the theme root — so any large files anywhere in the repo are fair game without an explicit allowlist.Before you deploy
changeset