Flaky codex-core unified_exec test: race in reusing_completed_process_returns_unknown_process
Summary
I’m seeing an intermittent failure in codex-rs/core/src/unified_exec/mod.rs for test:
reusing_completed_process_returns_unknown_process
The failure appears timing-dependent rather than deterministic.
What fails
After sending exit to an interactive shell, the test currently expects the next write_stdin poll to return UnknownProcessId immediately.
Intermittently, the first poll can instead return a final completed-process response, and only the subsequent poll returns UnknownProcessId.
Failure signature
The observed failure path is consistent with:
expected unknown process error
when the first post-exit poll returns Ok(...) instead of Err(UnknownProcessId { ... }).
Why this looks flaky
This appears to be a race between:
- Process completion and final output delivery.
- Removal of the process from the manager store.
- The first post-exit polling call in the test.
Reproduction
This is intermittent, so single runs may pass. Repeating the exact test increases repro chance:
for i in $(seq 1 200); do
cargo test -p codex-core reusing_completed_process_returns_unknown_process -- --exact --nocapture || break
done
Expected behavior
Please clarify intended contract for the first post-exit poll:
- Must it always be immediate
UnknownProcessId? - Or is one final terminal response acceptable before
UnknownProcessId?
If option 2 is acceptable, the current test assertion is too strict and can flake.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗