Repository navigation
test: wait for the parent's ack before utility children exit - #55082
Conversation
deepak1556
left a comment
There was a problem hiding this comment.
I don't think we should add a sync IPC round trip to the process.exit() path here. In Node.js, the api is explicitly documented to terminate the process immediately even when async I/O is still pending, and parentPort.postMessage() is an async IPC write.
The distinction from #54924 is that DispatchPendingMessages() drains messages that have already arrived on the browser's connector before emitting 'exit', whereas this PR tries to guarantee that in-flight child writes are flushed before process termination.
If a caller or test needs guaranteed delivery before calling process.exit(), it should wait for an acknowledgement from the parent (or exit after the parent handles the message) rather than calling postMessage() followed immediately by process.exit().
|
Thanks, that makes sense. The catch is that the tests now need what was taken out in #54924. @ckerr and @dsanders11 asked for the ack handshake in If this direction works, I'll replace this PR's change with that branch, retitled as Generated by Claude Code |
|
Yes, let's bring back the ack handshake in |
process.exit() does not wait for pending postMessage() writes, so a utility child that exits right after posting can lose its message. Restore the acknowledgement handshake that #54924 removed from the api-net fixture and helper, and add it to the env-app and js2c-code-cache fixtures, so those children only exit once the parent has acknowledged their message. The #54924 test no longer posts right before exiting. The child posts its parentPort messages, then posts on a transferred MessagePortMain and exits only when the parent replies there. parentPort and the port share the same ordered Mojo channel, so all of the parentPort messages have reached the parent when the port message does. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LPMvJBQiyP6b7QjatACmnS
6895c95 to
6c21301
Compare
|
Updated in 6c21301. The ack handshake is back in One thing to flag: with the barrier, the test no longer exercises the #54924 drain. When the browser's Connector reads the first parentPort message, it queues dispatch tasks for everything else already in the pipe. So by the time the port signal reaches JS, all 20 messages are queued ahead of the child's exit, and Generated by Claude Code |
|
No Release Notes |
|
I have automatically backported this PR to "43-x-y", please check out #55122 |
|
I have automatically backported this PR to "45-x-y", please check out #55123 |
|
I have automatically backported this PR to "44-x-y", please check out #55124 |
|
I have automatically backported this PR to "42-x-y", please check out #55125 |
Description of Change
As @deepak1556 pointed out,
process.exit()does not flush asynchronouspostMessage()writes, so a utility child that posts right before exiting can lose its message. Tests that need the message delivered now wait for the parent's ack before the child exits, restoring the handshake that #54924 removed in the api-net fixture and helper and adding it to the env-app and js2c-code-cache fixtures. The #54924 test no longer posts right before exiting: the child posts itsparentPortmessages, then posts on a transferredMessagePortMainand exits only when the parent replies there, which works as a barrier becauseparentPortand the port share the same ordered Mojo channel.🤖 Generated with Claude Code
https://claude.ai/code/session_01LPMvJBQiyP6b7QjatACmnS
Checklist
Release Notes
Notes: none