Repository navigation
fix: preserve JSON output for slow consumers at shutdown - #7428
Conversation
There was a problem hiding this comment.
All reported issues were addressed across 3 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
|
Merging this PR will not alter performance
Comparing Footnotes
|
|
Addressed all four inline review findings in 7f65b46 and updated the PR description. Full macOS validation: 11,258 unit tests passed, 159 skipped, 78.99% coverage; Ruff, Pyright, and commit hooks (including ty) passed. I also investigated the CodSpeed report for test_state_access[get_handler]. That benchmark does not enter the modified output-supervisor path: it passed locally with _OutputPump construction patched to raise if called. This PR changes no state-handler access code, and the CodSpeed comparison warns that its runtime environments differ. That evidence does not establish a regression caused by this change. |
|
Review notes from running this branch (head CI: the only red job is Finding: shutdown is only bounded once the child has exited. Nits
Possible solution: the usual structure in supervisors is to split reading from writing. One thread reads the child's pipe into a bounded queue and a second thread writes the queue to the consumer. The reader never blocks on a slow consumer, so the child never stalls. Shutdown then becomes "read to EOF (or the existing idle limit), then flush the queue under one wall deadline". That would replace Generated by Claude Code |
A slow consumer can lose JSON log output when the supervised command exits: the macOS unit run received only 157 of 200 lines because the five-second drain limit also counted time blocked forwarding output.
Exclude completed and ongoing writes from the five-second active drain budget. Capture each pump's monotonic time and cumulative write duration together under a lock, so a write completing during shutdown cannot corrupt the cutoff. Keep the idle limit for silent descendants and add a shared 30-second wall deadline so a stalled consumer or lingering writer cannot prevent shutdown.
Cover slow stdout and stderr consumers with normal and shortened active budgets, snapshot accounting during and after writes, and lingering writers blocked by unread stdout or stderr pipes. The race and stalled-consumer regressions reproduced the review findings before the fixes. Add a reflex-base changelog fragment documenting the shutdown limit.
Type of change
Validation