test: drain CLI subprocess output before waiting for exit - #279
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 7, 2026, 4:17 AM ET / 08:17 UTC. ClawSweeper reviewWhat this changesThe PR drains CLI subprocess stdout and stderr concurrently, shares the existing test pipe reader with FileHandle ownership, and adds a large-output regression test. Merge readiness✅ Ready for maintainer review This remains a useful, focused fix: current main and v0.15.1 retain the pipe-blocking sequence. No introduced correctness defect was found, and the collaborator-authored PR is protected from automatic closure. Priority: P2 Review scores
Verification
How this fits togetherimsg's CLI tests launch subprocesses and inspect their output and exit status. This test helper collects both output streams so pipe capacity cannot prevent the child from finishing. flowchart TD
A[CLI test arguments] --> B[Launch subprocess]
B --> C[Standard output reader]
B --> D[Standard error reader]
B --> E[Bounded exit wait]
C --> F[Captured output and exit status]
D --> F
E --> F
F --> G[Test assertions]
Before mergeNone. Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Keep concurrent draining in the shared test helper, preserving exit-status assertions, timeout behavior, and single-owner descriptor cleanup. Do we have a high-confidence way to reproduce the issue? Yes, source inspection establishes the failure path: output exceeding pipe capacity blocks the child while the parent waits for exit. The supplied body reports a before/after reproduction; this review did not execute it. Is this the best way to solve the issue? Yes, reusing the existing reader for both streams is a narrow repair, and FileHandle ownership preserves safe cleanup without changing production behavior. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 646ea7af9616. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Verification for
Exact-head macOS/Linux CI: https://github.com/openclaw/imsg/actions/runs/34099630319. This test-only repair can land before the independent transport-isolation PR #277. |
CLI subprocess tests could hang when the child filled stdout or stderr: the helper waited for process exit before reading either pipe. On a Mac whose available pipe capacity had fallen to 512 bytes, even the missing-database diagnostic reproduced the deadlock, including with tests run serially.
Drain both streams concurrently through the existing test pipe reader, then collect them after the child exits. Keep the three-second timeout and all CLI assertions unchanged. FileHandle owns each read descriptor so concurrent capture and cleanup cannot double-close it.
Validation: the new real subprocess regression writes 128 KiB to each stream; it timed out before the repair and passed in 0.059 seconds afterward. The previously failing built-CLI diagnostic test and existing large-stdout capture regression also pass. Full-suite, lint, and review results are recorded in the proof comment.
This is independent of #277: that PR isolates transport choice, while this change fixes output capture. Changelog notes are consolidated in the final release-notes PR.