Skip to content

fix(ts): flush staged files through a writable handle so writes work on Windows - #1058

Closed
gummy789j wants to merge 2 commits into
developfrom
fix/windows-atomic-write-fsync
Closed

gummy789j wants to merge 2 commits into
developfrom
fix/windows-atomic-write-fsync

Conversation

@gummy789j

Copy link
Copy Markdown
Collaborator

Problem

On Windows, a command that stores a file through AtomicFileStore fails in 4.16.0:

{"code":"io_error","message":"could not complete atomic text write","details":{"code":"EPERM"}}

fsyncFile opened the staged file read-only before flushing it. macOS and Linux flush a read-only handle; Windows flushes only a handle opened for writing and answers EPERM. The npm package and the standalone executable share this code. It was seen with import ledger on a Windows machine and with config on the Windows runner. Nothing wrote a file on Windows before a release: the unit tests run on Ubuntu, and the executable check stopped at device_not_found, before any write.

Change

  • fsyncFile opens the staged file with r+. The callers pass only files this process has just written with mode 0600, and r+ neither truncates nor creates.
  • scripts/verify-standalone.mjs writes a config value into its isolated home and reads it back, so the standalone workflow runs a write on each of the five targets.

Evidence

Run on the proof branch chore/node-sea-proof, which builds the same source into an executable on the five release runners:

  • the new check without the fix: windows-2022 fails with the EPERM above, the other four targets pass (run 44494565013);
  • the new check with the fix: all five targets pass (run 44494603419).

Locally: the file store unit tests (21 passed) and npm run typecheck.

Not covered

  • The unit tests still run on Ubuntu only.
  • No run here used a Ledger device on Windows.

@gummy789j gummy789j closed this Nov 19, 2026
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.

1 participant