Skip to content

graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs

Python

test(http): guard the #177 first assertion so a non-WriteFailed result can't hang the binary

Rach Pradhanbaaaf3117b1e
diff --git a/src/http.zig b/src/http.zig
index 234a16fc..9b5e2370 100644
--- a/src/http.zig
+++ b/src/http.zig
@@ -424,7 +424,19 @@ test "post (#177): a send-failed connection is not re-pooled — the next reques
const big = try gpa.alloc(u8, 8 * 1024 * 1024);
defer gpa.free(big);
@memset(big, 'x');
- try std.testing.expectError(error.WriteFailed, post(gpa, &client, provider, big));
+ // Assert the send fails with WriteFailed (the #177 signature). If it ever
+ // doesn't (a platform where the 8MB write buffers and the failure only
+ // surfaces later at head-read), release the server task's still-pending
+ // second accept() with a throwaway dial before failing — otherwise the
+ // deferred fut.await would hang the test binary, same as the second post.
+ if (post(gpa, &client, provider, big)) |resp| {
+ gpa.free(resp);
+ if (std.Io.net.IpAddress.connect(&bound, io, .{ .mode = .stream })) |s| s.close(io) else |_| {}
+ return error.TestExpectedError; // the send to a closed peer must fail
+ } else |err| if (err != error.WriteFailed) {
+ if (std.Io.net.IpAddress.connect(&bound, io, .{ .mode = .stream })) |s| s.close(io) else |_| {}
+ return err;
+ }
// The regression: without the poison this pulls dead conn 1 back out of
// the pool (no fresh dial) and fails with WriteFailed instead of