feat(coding-agent): diagnose when a child holds stdio open past exit#5758
Closed
Mearman wants to merge 1 commit into
Closed
feat(coding-agent): diagnose when a child holds stdio open past exit#5758Mearman wants to merge 1 commit into
Mearman wants to merge 1 commit into
Conversation
The earendil-works#5303 fix keeps reading after exit so output written by a detached descendant isn't truncated, but the trade-off mitsuhiko flagged on earendil-works#5753 stands: a descendant that writes continuously can hold the wait open until the command's own timeout kills the tree. That reads as a silent hang with no hint the process had already exited. Add an opt-in PI_STDIO_DEBUG=1 diagnostic that logs, on resolution, how long a process held stdio open past exit, how much it read in that window, and which path released the wait. Gated like PI_TIMING, off by default, and only fires when output actually arrived after exit (the timeout-relevant case).
Member
|
I don't want to add something like this for the moment. Let's cross that line when it comes up :) |
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.
Follow-up to #5753. When reviewing that PR you noted it doesn't change that we can end up waiting for the actual bash timeout to kick in. That's true and it's the right behaviour — if a detached descendant keeps writing after the shell exits, re-arming the grace is what stops us truncating the tail. But it's invisible: the command reads as a slow hang with nothing to say the process itself had already exited and a held-open pipe is what kept us reading.
This adds an opt-in
PI_STDIO_DEBUG=1that logs, when the wait resolves, how long a process held stdio open past exit, how much it read in that window, and which path released us (clean eof / idle grace / close). Gated exactly likePI_TIMING, off by default, zero overhead when unset, and it only fires when output actually arrived after exit — i.e. the case that can stretch to the timeout, not every backgrounded handle.Example line:
npm run checkand./test.shboth pass. Two tests intest/child-process-stdio-debug.test.ts: one that the line is emitted with the flag on, one that it stays silent with it off.