Repository navigation
fix(ssg): copy the live output folder under the directory lock for --incremental - #156
Merged
Merged
Conversation
…incremental Concurrent incremental builds copied the live output folder into staging before taking the lock, so a build could stage from a half-swapped tree or race the other build's rename. The copy now runs under the same lock as the swap, held only for the copy and not for site generation.
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
askr ssg --incrementalcopied the live output folder into its staging folder before taking the directory lock; only the final swap ran under it. Two concurrent incremental builds could race: on Windows a rename fails with EPERM while the other build is copying, and on any OS a build could stage from a half-swapped folder.The copy now runs under the same lock as the swap through a new
copyTargetIntoStagehelper. The existence check happens inside the lock too, so a target that is momentarily absent mid-swap is never mistaken for a missing output folder. The lock is held only for the copy, not for site generation, so builds are not serialised for their whole duration. Each build still publishes a complete tree, so two concurrent runs both succeed and the last swap wins, and neither publishes a partial tree.Tests
falsewith an empty stage.npm run lint,typecheck,test:coverage(288 tests),test:changelog,buildandtest:publintpass.Closes #155