Skip to content

Stop the PATCH read-back test racing a closing socket - #129

Merged
sionsmith merged 1 commit into
mainfrom
fix/flaky-patch-read-back-test
Oct 26, 2026
Merged

sionsmith merged 1 commit into
mainfrom
fix/flaky-patch-read-back-test

Conversation

@sionsmith

Copy link
Copy Markdown
Contributor

api::client::tests::patch_with_an_empty_body_of_unknown_length_reads_the_resource_back failed once while I was verifying #119 locally:

called `Result::unwrap()` on an `Err` value: Other(Update succeeded, but reading it back failed: Network error: error sending request for url (http://127.0.0.1:60190/teams/t1))

Cause: the test's raw HTTP server closes every connection after replying. Its chunked 200 did not send Connection: close, though, so reqwest put the connection back in its pool and sent the read-back GET down it. If the server's close landed first, that GET failed.

Reproduced: adding a 50 ms sleep before the server's shutdown() makes the test fail every time, with the same error.

Fix: the chunked reply now sends Connection: close, as the other reply in the test already did. With the 50 ms sleep still in place, the test passes. This changes only the test: the client code is correct, and Graph does not close a keep-alive connection right after answering.

Separately, this test passed 300 isolated runs and 40 full-suite runs on main, so the race is rare. CI has never hit it.

🤖 Generated with Claude Code

patch_with_an_empty_body_of_unknown_length_reads_the_resource_back
failed intermittently with "Update succeeded, but reading it back
failed: Network error: error sending request". Its raw server closes
every connection, but the chunked reply did not say so, so reqwest
pooled the connection and could send the read-back GET down it as the
server closed it. A 50 ms pause before the server's close reproduces
the failure every time; with Connection: close on the reply it passes.
The client code is unchanged: Graph does not close a keep-alive
connection right after answering.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sionsmith
sionsmith merged commit 744b885 into main Oct 26, 2026
6 checks passed
@sionsmith
sionsmith deleted the fix/flaky-patch-read-back-test branch October 26, 2026 22:36
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.

1 participant