Skip to content

Don't compare stat.dev when streaming zip entries#285

Merged
GrahamCampbell merged 1 commit into
mainfrom
fix/zip-stat-dev-windows-280
Jun 6, 2026
Merged

Don't compare stat.dev when streaming zip entries#285
GrahamCampbell merged 1 commit into
mainfrom
fix/zip-stat-dev-windows-280

Conversation

@GrahamCampbell
Copy link
Copy Markdown
Contributor

On Windows, packaging could fail with "Cannot read file ... due to: file changed between metadata collection and stream open" even when the file had not changed. The streaming zip writer collects each file's metadata with a path-based fs.stat() and then re-checks it against a handle-based fileHandle.stat() immediately before streaming the entry, and on Windows these two stat sources report a different device id (dev) for the very same unchanged file because libuv's path fast-path does not read the volume serial number while the handle path does. The safety check interpreted that mismatch as a changed file and aborted the whole package.

This drops dev from the comparison, because it is unreliable across the two stat methods and contributes nothing useful here, while keeping the inode, size and modification-time checks that actually detect a file changing underneath us. Both stats are now collected with the bigint option so that the inode and modification time are compared as exact integers rather than a precision-losing Number and a floating-point millisecond value. The same code path is used for layer packaging, so that is covered as well.

Resolves #280.

@GrahamCampbell GrahamCampbell changed the title fix(package): don't compare stat.dev when streaming zip entries Don't compare stat.dev when streaming zip entries Jun 6, 2026
@GrahamCampbell GrahamCampbell merged commit 1abb7e4 into main Jun 6, 2026
8 checks passed
@GrahamCampbell GrahamCampbell deleted the fix/zip-stat-dev-windows-280 branch June 6, 2026 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows packaging false-positive: Cannot read file .babelrc due to: file changed between metadata collection and stream open

1 participant