Repository navigation
Fix race when parallel workers copy static assets - #1178
Merged
Merged
Conversation
When parallel test workers exit at roughly the same time, each one calls HTMLFormatter#copy_static_assets against the shared coverage directory. cp_r with remove_destination: true would have one process unlink an asset (e.g. favicon_red.png) just before another process also tried to unlink it, raising Errno::ENOENT. Copy each file via a uniquely-named temp file in the destination directory and then File.rename onto the final path. rename is atomic on POSIX and overwrite-safe, so concurrent writers can no longer race on the same path.
sferik
force-pushed
the
fix-static-asset-copy-race
branch
from
May 4, 2026 21:59
d57ca84 to
dfc48da
Compare
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.
The
parallel_tests.featurecucumber scenarios fail intermittently on a clean main withErrno::ENOENTfrom insideHTMLFormatter#copy_static_assets. Reproducible locally, ~2 of 5 scenarios fail per run.When parallel rspec workers exit at roughly the same time, each one runs the formatter against the shared coverage directory.
FileUtils.cp_r(path, dest_dir, remove_destination: true)performs an unlink-then-copy, and one process ends up unlinking an asset (e.g.favicon_red.png) just before another process also tries to unlink it.Switched to per-file copy via a uniquely-named temp file in the destination directory followed by
File.rename. Rename is atomic and overwrite-safe on POSIX, so two writers landing on the same path no longer race; whichever finishes last wins, and the file is always coherent. Thepublic/directory is flat so we don't lose anything by walking files individually instead of usingcp_r.