Repository navigation
fix: wait for a plugin command's pipes to close after its exit - #6818
Merged
Merged
Conversation
janicduplessis
force-pushed
the
fix/6803-host-exec-close
branch
2 times, most recently
from
December 2, 2026 16:36
1761b56 to
57f536b
Compare
janicduplessis
force-pushed
the
fix/6803-host-exec-close
branch
from
December 2, 2026 16:42
57f536b to
80d074c
Compare
Collaborator
Author
|
Review outcome for 80d074c, which has the same tree as the reviewed 57f536b. It was re-pushed only because the GitHub Actions incident dropped the first pull_request event.
|
janicduplessis
marked this pull request as ready for review
December 2, 2026 17:06
janicduplessis
enabled auto-merge (squash)
December 2, 2026 17:06
This was referenced Dec 2, 2026
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.
Description
Plugin
host.execcalls could return code 0 with empty stdout on Linux. Inexact-offload-worker.integration.test.ts, that turned Exact'sgit rev-parse HEADon its pinned checkout into anexact-tools"not at commit" refusal. The test failed the 2.3.0 release gate and Full suite on 450fd2f, even after #6815.host.execruns withcleanupOnExit: at the leader'sexitevent Stim kills its process group and then destroys the pipes. Node often seesexitbefore it has read what the child already wrote. #6815 put a drain before the destroy that reads event-loop turns until one turn delivers nothing. A Linux CI run with every plugingitcall, drain and finish logged (run 46922914607) shows that rule doesn't hold. Every failing call loggeddrain turns=1 read=0 closed=falseand thenfinish status=0 out=0B: the first turn ran before any poll had read git's 41-byte answer, so the drain stopped with the data still in the pipe.Solution
At an exit cleanup, wait for the pipes to actually close, up to 1 s, instead of counting turns (exec.ts). The group has already been killed, so in the normal case the pipes reach EOF at once and everything the child wrote is read. One
setImmediateturn after the wait lets the poll phase read what is left if the event loop stalled past the second.host.execkeepscleanupOnExit. Without it, a plugin command whose leader leaves a child holding its stdout would wait for that child until its timeout, even after succeeding. The new test row covers that.Known limit: a process that escaped the group (its own session) and still holds a pipe can add its writes from that second to the output. It also makes every
cleanupOnExitcaller,spawnManagedCapture.finish()included, wait out that second. Shipped plugins don't do this. Exact runs only shortgit,bunandrustupprobes,exact.mjs helpand its sweep'scleanthroughhost.exec, and Godot uses none. This PR removes the #6815 test row that asserted a detached descendant's late write is left out, because the close-wait accepts it. #6816 tracks the exact-bytes question, with two designs that would return only what the leader wrote.This is the second fix for #6803 after #6815 didn't hold on Linux, so #6815 and this PR count as one review chain under the step-back rule. A Fable consult recommended this close-wait over another drain mechanism for 2.3.0, with the detached-writer case tracked in #6816 rather than fixed here.
Test plan
exact-offload-worker.integration.test.tson the Linuxtest (node 22)andtest (node 24)jobs is the regression check. It failed 1 to 4 of its 8 tests per job with fix: keep a child's buffered output when cleanup starts at its exit #6815's drain: release gate run 46908610161, Full suite run 46908685305 and diagnostic run 46922914607.exec.integration.test.ts"cleanup at leader exit": one row keeps 16 KiB that was still unread at exit, and another returnsreadyin well under its timeout when the leader left a child holding stdout. Both fail on the code before fix: keep a child's buffered output when cleanup starts at its exit #6815. Neither reproduces the Linux turn race on macOS.host.exec,exec.integration.test.ts,report-listing.test.tsandoffload-worker-pod-rekey.integration.test.tspass (283 tests).pnpm run lintpasses.Fixes #6803