From d7009dc488f5e332274096b1b01f54702337f5f7 Mon Sep 17 00:00:00 2001 From: Kyle Isom Date: Tue, 22 Sep 2026 18:28:18 -0700 Subject: [PATCH] brokerd tests: read the final frame after the handler closes, on macOS The test client set its read timeout before every frame. On macOS that fails with EINVAL once the handler has sent its final frame and closed, so every admin test that reads a second frame failed there (40 runs of 40 at 2408e2c). The frame is already buffered, so the client now takes that one refusal as the peer having closed and reads it. The plan's copy changes with it. Co-Authored-By: Claude Opus 5.5 (1M context) --- crates/brokerd/tests/support/client.rs | 10 ++++++---- .../M3a/files/crates/brokerd/tests/support/client.rs | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/crates/brokerd/tests/support/client.rs b/crates/brokerd/tests/support/client.rs index 65ef1e2..fd41017 100644 --- a/crates/brokerd/tests/support/client.rs +++ b/crates/brokerd/tests/support/client.rs @@ -53,11 +53,13 @@ pub fn open( client } -/// The next frame, waiting at most ten seconds. +/// The next frame, waiting at most ten seconds. Once the handler has closed its end, macOS +/// refuses the timeout with EINVAL (22); the frame is buffered by then and the read cannot block. pub fn next(stream: &mut UnixStream) -> Envelope { - stream - .set_read_timeout(Some(Duration::from_secs(10))) - .unwrap(); + if let Err(e) = stream.set_read_timeout(Some(Duration::from_secs(10))) { + let peer_closed = cfg!(target_vendor = "apple") && e.raw_os_error() == Some(22); + assert!(peer_closed, "set_read_timeout: {e}"); + } proto::read_frame(stream).unwrap() } diff --git a/docs/plans/M3a/files/crates/brokerd/tests/support/client.rs b/docs/plans/M3a/files/crates/brokerd/tests/support/client.rs index 65ef1e2..fd41017 100644 --- a/docs/plans/M3a/files/crates/brokerd/tests/support/client.rs +++ b/docs/plans/M3a/files/crates/brokerd/tests/support/client.rs @@ -53,11 +53,13 @@ pub fn open( client } -/// The next frame, waiting at most ten seconds. +/// The next frame, waiting at most ten seconds. Once the handler has closed its end, macOS +/// refuses the timeout with EINVAL (22); the frame is buffered by then and the read cannot block. pub fn next(stream: &mut UnixStream) -> Envelope { - stream - .set_read_timeout(Some(Duration::from_secs(10))) - .unwrap(); + if let Err(e) = stream.set_read_timeout(Some(Duration::from_secs(10))) { + let peer_closed = cfg!(target_vendor = "apple") && e.raw_os_error() == Some(22); + assert!(peer_closed, "set_read_timeout: {e}"); + } proto::read_frame(stream).unwrap() }