From 4154ecc46797869d9d35b7f84c8ba485f093deb8 Mon Sep 17 00:00:00 2001 From: Sion Smith Date: Mon, 26 Oct 2026 22:24:55 +0000 Subject: [PATCH] test: stop the PATCH read-back test racing a closing socket 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 --- src/api/client.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/api/client.rs b/src/api/client.rs index 3c16a3c..cb6ded3 100644 --- a/src/api/client.rs +++ b/src/api/client.rs @@ -1587,8 +1587,11 @@ mod tests { /// connection closing; it must still be read back, not parsed. #[tokio::test] async fn patch_with_an_empty_body_of_unknown_length_reads_the_resource_back() { + // The server closes every connection, so the chunked reply says so too. + // Without `Connection: close` the client pools it and can send the + // read-back GET down the socket just as the server closes it. let replies: [&'static [u8]; 2] = [ - b"HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\n\r\n0\r\n\r\n", + b"HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\nConnection: close\r\n\r\n0\r\n\r\n", b"HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n", ]; for reply in replies {