fix: stop stdin forwarder from 409ing after the operation is already terminal - #18
Merged
Merged
Conversation
…terminal A command that finishes without ever reading local stdin still leaves StdinForwarder waiting on the shared queue. StdInReader's shutdown then pushes a synthetic close frame through that queue, which the forwarder sends to operation_subprocess_stdin -- 409ing since the operation is already SUCCESS. Give StdinForwarder an abandon() method and call it once stream_events_until_close (or cmd_run's BrokenPipeError handler) knows the operation is terminal, so a late queue item is dropped instead of forwarded.
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
run(including implicit runs insidecontree shell) spawns a backgroundStdinForwarderthat drains local stdin into the operation, even when the command never reads stdin.StdInReader's shutdown pushes a synthetic close frame into the queue the forwarder is still waiting on. The forwarder dutifully POSTs it viaoperation_subprocess_stdin-- but the operation is alreadySUCCESS, so the API returns 409 and the CLI logsstdin forwarding failed, remaining input was not sent.StdinForwardergains anabandon()method.stream_events_until_closecalls it as soon as the operation is known terminal (normal completion, and the hard-cancel on a second Ctrl-C);cmd_run'sBrokenPipeErrorhandler calls it too, since that path also cancels the operation. Once abandoned, the forwarder drops any further queue item instead of sending it. Genuine stdin forwarding (e.g.cat | md5sum, which blocks on real EOF) is unaffected -- its data and close frame are already sent before the operation goes terminal.Reproduction
Any command that completes without reading stdin to EOF triggers this -- the error is cosmetic (the command's own output is correct) but appears on nearly every shell command.