Fix stdio-to-uds peer-close flake#13882
Conversation
20852f2 to
676103d
Compare
22a8636 to
84c6afe
Compare
|
@codex review this |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 84c6afe447
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| "anyhow", | ||
| "chrono", | ||
| "clap", | ||
| "codex-otel", |
There was a problem hiding this comment.
Remove unintended codex-state lockfile dependency
Cargo.lock now adds codex-otel under the codex-state package, but codex-rs/state/Cargo.toml does not declare that dependency. This lockfile drift can make cargo --locked/CI fail with a lock-update-required error, even though the stdio-to-uds change is unrelated.
Useful? React with 👍 / 👎.
codex-rs/stdio-to-uds/src/lib.rs
Outdated
| stream | ||
| .shutdown(Shutdown::Write) | ||
| .context("failed to shutdown socket writer")?; | ||
| // The peer can close immediately after sending its response. On macOS that |
There was a problem hiding this comment.
Are we certain that this can only happen on macOS?
| Ok(()) | ||
| }); | ||
|
|
||
| Command::new(codex_utils_cargo_bin::cargo_bin("codex-stdio-to-uds")?) | ||
| let stdin = std::fs::File::open(&request_path).context("failed to open child stdin fixture")?; |
There was a problem hiding this comment.
I feel like either here or in a docstring on pipes_stdin_and_stdout_through_socket(), some of the PR body should be memorialized as a comment to explain why this test code is complicated.
If I understand correctly, a key change is using read_exact() in server_thread instead of read_to_end() to eliminate the dependency on EOF timing.
I'm unclear whether the move from assert_cmd::Command to std::process::Command is necessary to ensure the test is no longer flaky. Is it mainly there to build up server_events so that if the test does fail, the error includes the server_events received thus far, making it easier to debug?
What changed
codex-stdio-to-udsnow toleratesNotConnectedwhenshutdown(Write)happens after the peer has already closed.Why this fixes the flake
shutdown(Write)can reportNotConnectedeven though the interaction already succeeded.Scope