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() }