fix(theme): ignore atomic-write tmp files in the theme dev watcher#7870
Conversation
Editor tools (including AI coding assistants) create temporary files like `blocks/foo.liquid.tmp.93809.4dbd82e0b95a` during atomic save operations, then delete them within milliseconds. Because the per-event debounce fires independently for `add` and `unlink`, Shopify's file watcher sees the add event, attempts to upload the invalid asset key, and crashes the dev server. Adding `**/*.tmp.*` to `DEFAULT_IGNORE_PATTERNS` prevents chokidar from emitting events for these files entirely. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
| '**/config.yml', | ||
| '**/node_modules/', | ||
| '.prettierrc.json', | ||
| '**/*.tmp.*', // Atomic-write temp files (e.g. blocks/foo.liquid.tmp.93809.4dbd82e0b95a) |
There was a problem hiding this comment.
Thanks for this @andershagbard. We're just having a discussion internally here because there are going to be themes that already contain files with .tmp. in the name that this would break.
The purpose behind the PR makes sense but we need to think of how to make sure our fix doesn't break existing themes.
There was a problem hiding this comment.
I added this because the devserver will crash because the API doesn't accept that file name. I assume it's blocked serverside, and therefore these files would not exist?
There was a problem hiding this comment.
Correct me if I am wrong, but I think this can be enforced in all folders except assets.
I am getting these errors in the theme editor:
FileSaveError: Must have a .liquid file extension
FileSaveError: "sections/test.json.tmp.1231231" contains illegal characters
There was a problem hiding this comment.
You’re right that files like sections/test.json.tmp.1231231 are not valid theme files and won’t be accepted server-side.
The piece I’m worried about is the breadth of **/*.tmp.*. DEFAULT_IGNORE_PATTERNS is used for the initial file glob too, so this can hide real files (e.g. snippets/test.tmp.liquid).
Maybe we can narrow this to non-asset theme folders and only ignore files where the temp suffix is appended after a valid extension?
[
'**/blocks/**/*.liquid.tmp.*',
'**/layout/**/*.liquid.tmp.*',
'**/snippets/**/*.liquid.tmp.*',
'**/config/**/*.json.tmp.*',
'**/locales/**/*.json.tmp.*',
'**/sections/**/*.{liquid,json}.tmp.*',
'**/templates/**/*.{liquid,json}.tmp.*',
]That should catch sections/test.json.tmp.1231231 and blocks/foo.liquid.tmp.93809.4dbd82e0b95a, but not ignore valid files like snippets/test.tmp.liquid or any legitimate assets/* files.
As a personal workaround for now you could also add the following to your .shopifyignore:
/\.tmp\.[0-9]+(\.[0-9a-fA-F]+)?$/Replace the broad `**/*.tmp.*` glob with directory-specific patterns scoped to the theme file types that actually use atomic writes. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: Gray Gilmore <graygilmore@gmail.com>
Summary
This is an error which happens because Claude Code generates these tmp files. Not sure if other tools use the same method or naming.
blocks/foo.liquid.tmp.93809.4dbd82e0b95aduring atomic save operations and delete them within milliseconds.addandunlinkevents, the file watcher sees theadd, tries to upload the invalid asset key to Shopify, and crashesshopify theme dev— requiring a manual restart.**/*.tmp.*toDEFAULT_IGNORE_PATTERNSso chokidar never emits events for these files.Root cause
queueFsEventdebounces per${fileKey}:${eventName}, meaningaddandunlinkare queued separately. By the time the 250ms debounce fires foradd, the file is already gone — but Shopify still gets the upload attempt with an invalid key.Test plan
**/*.tmp.*is present in chokidar'signoredoptiontheme-fstests pass🤖 Generated with Claude Code