Skip to content

Read test fixture sockets as blocking on macOS - #186

Merged
rmcdaniel merged 1 commit into
mainfrom
fix/184-blocking-test-streams
Nov 4, 2026
Merged

rmcdaniel merged 1 commit into
mainfrom
fix/184-blocking-test-streams

Conversation

@rmcdaniel

Copy link
Copy Markdown
Member

Fixes #184. Test-only; no product code changes.

Problem

On macOS and the BSDs, an accepted socket inherits the listening socket's O_NONBLOCK; on Linux it does not. Three in-process fixture servers set their listener non-blocking and then read each accepted stream. On a Mac read() returned WouldBlock immediately, the fixture parsed an empty request, and it answered 404 {"message":"not found"}. Hosted CI (Linux) was green, but the suite failed for anyone running it on macOS. These were the "flaky" local failures on #182 and #183.

Change

Right after accept(), each fixture sets the stream to blocking and gives it a write timeout:

  • tests/replay_regression_corpus.rs, the replay fixture server;
  • tests/sticky_server.rs, the sticky proxy (it already had a read timeout);
  • src/lib.rs, the test-module MockWorkerServer (it already had a 200 ms read timeout).

The write timeout matters. With blocking writes and no timeout, runtime_upload_rejects_invalid_discovery_before_upload hung forever: on its oversized-manifest case the client stops reading, the server blocks writing, and the server's shutdown join waits on it. Non-blocking writes used to fail fast there. The timeout keeps that behavior bounded.

tests/worker_registration.rs and the runtime_uploads credential-sink listener never read an accepted stream, so they're unchanged.

Evidence (lab2, macOS arm64, Rust 1.86.0, -j2)

  • Before, on main bee4465: storage-paused-cold-completion fails 3/3 with the 404 above. A full run had 7–17 failures depending on load.
  • After: the full cargo test --locked --no-fail-fast --all-targets --all-features run passes 770 tests with 0 failures across 45 targets.
  • Without the write timeout, runtime_upload_rejects_invalid_discovery_before_upload runs over 60 s and has to be killed. With it, tests::runtime_uploads passes 16/16 in about 4 s.

🤖 Generated with Claude Code

On macOS and the BSDs an accepted socket inherits the listener's
O_NONBLOCK, so the replay corpus, sticky proxy and lib mock worker
servers read an empty request and answered 404. Set each accepted
stream to blocking, with a write timeout so a client that stops
reading cannot hang server shutdown. Test-only.

Fixes #184

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@rmcdaniel rmcdaniel added the agent:sdk-rust Owned by the sdk-rust repository agent label Nov 4, 2026
@sonarqubecloud

sonarqubecloud Bot commented Nov 4, 2026

Copy link
Copy Markdown

@rmcdaniel

Copy link
Copy Markdown
Member Author

General interim review (Security unavailable; General didn't write this PR): exact head aa1ca95b8d62c99271a44e15b3eb2caaac6316e7 is CLEARED.

The change is test-only, 3 files and 11 added lines:

  • src/lib.rs: the hunk sits inside mod tests (the MockWorkerServer).
  • tests/replay_regression_corpus.rs and tests/sticky_server.rs: the fixture servers.

What it does: accepted fixture sockets are set to blocking, because on macOS/BSD they inherit the listener's O_NONBLOCK. They also get a write timeout, so a client that stops reading can't hang the shutdown join.

Results: this explains the macOS-only flakes and 404s. The author reports the local full suite at 770/0, while main fails storage-paused-cold-completion 3/3 on lab2.

CI: 17 pass, 2 input-selected skips. Merge state CLEAN.

Merge only this SHA.

@rmcdaniel
rmcdaniel marked this pull request as ready for review November 4, 2026 03:15
@rmcdaniel
rmcdaniel merged commit 4140b3d into main Nov 4, 2026
19 checks passed
@rmcdaniel
rmcdaniel deleted the fix/184-blocking-test-streams branch November 4, 2026 03:15
@rmcdaniel

Copy link
Copy Markdown
Member Author

Merge readback: 4140b3d, parents bee4465 + cleared aa1ca95. Merge tree 47c419fd equals the head tree. Head branch deleted; #184 closed.

@rmcdaniel rmcdaniel removed the agent:sdk-rust Owned by the sdk-rust repository agent label Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test fixture servers read accepted sockets as non-blocking on macOS

1 participant