Conversation
This was referenced Sep 8, 2026
… alive The live-holder case wrote `pid: 1` and leaned on its own comment, "On Linux, PID 1 is almost always alive". Windows has no PID 1, so tryAcquireWriterLock read the holder as dead and acquired — the correct behaviour for a dead holder, and a failing assertion. The platform-specific part was the fixture, not the lock. A parked child process is alive on every platform, and not stealing from a live holder is what the lock actually promises, so the case now tests the promise rather than a number that happens to name a running process. The child is reaped in afterEach. Fixes colbymchenry#1752.
bompus
force-pushed
the
fix/writer-lock-live-holder
branch
from
September 15, 2026 22:53
46bfbdc to
bee1402
Compare
This branch has not been deployed
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.
Fixes #1752.
The problem
writer lock (#1740) > reports taken when a live foreign pid holds the lockfails on Windows, on a cleanmain, with nothing else present:The fixture writes
pid: 1as its live foreign holder and says so in its own comment — "On Linux, PID 1 is almost always alive." Windows has no PID 1, sotryAcquireWriterLockreads the holder as dead, clears the stale lock and acquires. That is the correct behaviour for a dead holder; the assertion is failing on the fixture, not on the lock.The change
Spawn a parked child and use its pid. It is alive on every platform, and "does not steal from a live holder" is what the lock actually promises — so the case now tests the promise rather than a number that happens to name a running process. On Linux it also stops depending on the ambient assumption about init. The child is killed in
afterEach.The sibling
clears a stale dead-pid lock and acquirescase still covers the dead-holder direction with2147483646, so both sides of the branch stay tested.Verification
__tests__/writer-lock.test.ts4/4 passbb204f8without the change: 1 failed / 3 passed, the case aboveI have not been able to run the Linux arm; the change is platform-neutral by construction, but worth a CI look.
Why I noticed
A downstream promotion pipeline gates on a zero-failure suite, so this single test blocked a Windows host from promoting any build of
main. Not urgent for the lock itself, which behaves correctly throughout.