fix: prevent theme dev from overwriting local files after throttled uploads#7041
Draft
graygilmore wants to merge 2 commits intomainfrom
Draft
fix: prevent theme dev from overwriting local files after throttled uploads#7041graygilmore wants to merge 2 commits intomainfrom
graygilmore wants to merge 2 commits intomainfrom
Conversation
chokidar's _handleFile listener compares mtimeMs and suppresses change events when mtime hasn't changed. Build tools that preserve timestamps (e.g. via touch --reference) cause silent misses on Linux/Windows. chokidar emits a raw event unconditionally, even when the mtime check suppresses the change event. This adds a raw event listener as a fallback: when a raw event fires, we start a short 100ms timeout. If chokidar's normal change event fires within that window, we cancel the timeout (normal path handled it). If the timeout expires, we trigger the handler ourselves. The existing handleFileUpdate already computes MD5 checksums and only syncs when content actually changes, so even if both paths fire, the checksum comparison prevents redundant uploads. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Failed uploads (e.g. THROTTLED) were unconditionally removed from unsyncedFileKeys in the .then() callback of uploadBatch, regardless of whether the upload actually succeeded. This allowed the polling loop in theme-polling.ts to see these unprotected files, detect a checksum mismatch, and overwrite local files with remote versions -- defeating the 'keep local' reconciliation choice. The fix checks uploadResults.get(file.key)?.success === true before removing from unsyncedFileKeys and incrementing the progress counter. Files that fail all retries remain in unsyncedFileKeys, preventing the polling loop from overwriting them. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
Coverage report
Test suite run success3816 tests passing in 1474 suites. Report generated by 🧪jest coverage report action from 9034f51 |
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.
Summary
unsyncedFileKeys, allowing the polling loop to overwrite local files with remote versions — defeating the "keep local" reconciliation choiceunsyncedFileKeyswhenuploadResultsconfirmssuccess: trueFixes https://github.com/Shopify/developer-tools-team/issues/1134
Details
In
buildUploadJob, the.then()callback afteruploadBatchunconditionally removed all files fromunsyncedFileKeysand incremented progress bybatch.length. SinceuploadBatchnever throws (it returns results withsuccess: true/false), the.then()fired even when uploads failed. This left failed files unprotected from the polling loop intheme-polling.ts, which would detect a checksum mismatch and download the remote version over the local file.The fix checks
uploadResults.get(file.key)?.success === trueper-file before removal. Files that fail all retries remain inunsyncedFileKeys, preventing polling overwrites.Test plan
unsyncedFileKeys🎩 Tophatting
shopify theme devand select "Keep the local version" at reconciliation🤖 Generated with Claude Code