Repository navigation
fix(windows): keep a handoff whose sender closed before the owner listened - #2393
Merged
Merged
Conversation
The keyed-handoff test failed when its delivery took more than a fixed three seconds, which only says the runner was loaded: the sender writes to the pipe and returns, and the owner delivers on its own goroutine. Wait until the delivery arrives, bounded by what is left of the test's deadline, so a loaded runner does not fail a correct handoff. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A second launch connects, writes and closes in one go. When it finishes before the owner's serve goroutine calls ConnectNamedPipe, the call fails with ERROR_NO_DATA rather than ERROR_PIPE_CONNECTED, and serve skipped the read, dropping the launch's files and links while the sender reported success. Treat ERROR_NO_DATA as connected and read the buffered message, as CPython's multiprocessing does (bpo-14725).
Add a deterministic test that runs sendInstance to completion before receiveInstance calls ConnectNamedPipe, and bound the handoff wait at 30 seconds instead of the rest of the test deadline, so a lost message fails quickly.
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
TestInstanceHandsOffByKeyfailed on a Windows runner withkey "two" did not receive its filesafter a fixed 3-second wait (run 45628280474, job 139254247142). The whole step took 4.4 seconds, so the runner was not slow: the handoff was lost.The cause is a race in
serve(internal/platform/windows/instance.go).servecallsCreateNamedPipeWand thenConnectNamedPipe;sendInstanceconnects, writes and closes in one go. If the sender finishes between those two calls,ConnectNamedPipefails withERROR_NO_DATA(232), notERROR_PIPE_CONNECTED(535).serveonly accepted 535, so it skippedReadFileand dropped the message, while the sender had already reported success. In a real app this silently loses the files and links a second launch hands over.servenow treatsERROR_NO_DATAas connected and reads the buffered message, as CPython'smultiprocessingPipeListenerdoes (bpo-14725). The per-connection logic moves intoreceiveInstanceand pipe creation intocreateInstancePipe, without other behavior changes.TestInstanceReceivesAClosedSenderreproduces the race deterministically: it creates the pipe, runssendInstanceto completion, then callsreceiveInstanceand checks the message arrives.TestInstanceHandsOffByKeywaits up to a fixed 30 seconds instead of 3. The earlier revision of this PR waited for the rest oft.Deadline(); on the hostgo tool nsgo testpasses no-timeout, so that was go test's 10-minute default, not three minutes, and a lost message would have hung the job for about ten minutes.Targets
core,base,ui,tsx, thensgotool)Screenshots
None; nothing visible changes.
Verification
go tool nsgo check -target windows ./internal/platform/windowspasses (windows_arm64 and windows_x64).windowsjob (go tool nsgo test -run '^TestInstance' ./internal/platform/windows).Checklist
changelog.d/fragment, not inCHANGELOG.md.