Skip to content

fix: stop stdin forwarder from 409ing after the operation is already terminal - #18

Merged
mosquito merged 1 commit into
masterfrom
fix/shell-stdin-forwarder-409
Aug 26, 2026
Merged

fix: stop stdin forwarder from 409ing after the operation is already terminal#18
mosquito merged 1 commit into
masterfrom
fix/shell-stdin-forwarder-409

Conversation

@mosquito

Copy link
Copy Markdown
Collaborator

Summary

  • Every run (including implicit runs inside contree shell) spawns a background StdinForwarder that drains local stdin into the operation, even when the command never reads stdin.
  • When such a command finishes quickly, the local StdInReader's shutdown pushes a synthetic close frame into the queue the forwarder is still waiting on. The forwarder dutifully POSTs it via operation_subprocess_stdin -- but the operation is already SUCCESS, so the API returns 409 and the CLI logs stdin forwarding failed, remaining input was not sent.
  • Fix: StdinForwarder gains an abandon() method. stream_events_until_close calls it as soon as the operation is known terminal (normal completion, and the hard-cancel on a second Ctrl-C); cmd_run's BrokenPipeError handler 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

(main) / $ cat /etc/os-release | md5sum
...
[ERROR] stdin forwarding failed, remaining input was not sent: HTTP 409: Operation is SUCCESS, not running

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.

…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.
@mosquito
mosquito requested a review from insomnes August 26, 2026 14:18

@insomnes insomnes left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@mosquito
mosquito merged commit 3ca64e2 into master Aug 26, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants