proxy: end writes that stall when no write timeout is set #351
All Vouch review confidence checks passed
Residual risk 0.19 = Change Risk (0.47) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.47 · 480 lines diff across 6 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.369
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #351"
general
weight: 0.35
hieblmi
With
writetimeout: 0, which keeps long-lived gRPC streams from being cut, nothing ends a write to a client that cannot complete. A client that never opens its HTTP/2 receive window, or stops reading its socket, keeps the handler and its stream open for as long as it keeps the connection.Before and after
Before
1. Aperture runs with
writetimeout: 0.2. A client opens a stream, for example
GET /or a whitelisted gRPC call, and never opens its receive window, or stops reading its socket.3. The handler's flush, or the write the server makes after the handler returns, waits.
4. Nothing times it out. The stream and its goroutine stay until the client closes the connection, and one connection can hold many such streams.
After
1. to 3. The same.
4. After
writestalltimeout(1m by default) the blocked write fails and the server resets the stream. If the socket itself is not read, the HTTP/2 server closes the connection.5. A stream that is only quiet between writes, such as a notification stream, is not affected: the deadline is only set while a write is in progress.
Fix
ServeHTTP, so preflight and error replies are covered too. It is only used whilewritetimeoutis 0; with a write timeout the rolling window already ends stalled writes.Hijack, so the hashmail WebSocket proxy still upgrades.writetimeoutis 0, the same value is the HTTP/2 servers'WriteByteTimeout, for clients that stop reading their socket.writestalltimeoutoption sets it, and0sturns it off. A negativewritetimeoutorwritestalltimeoutis now refused at startup.Tests
TestStallTimeoutEndsUnreadResponse: over h2c, a client with a zero receive window gets its stream reset, for a small body, a large body and a streamed backend response. Without the timeout, it does not.TestStallTimeoutEndsUnreadGRPCStream: the same for a gRPC stream, which flushes throughhttp.Flusher.TestStallTimeoutKeepsQuietStream: a gRPC stream quiet for three times the timeout keeps working.TestStallTimeoutKeepsPausedResponse: a response that pauses between writes without flushing keeps working.TestStallTimeoutKeepsGRPCChallenge: a gRPC client still sees the L402 challenge.TestStallTimeoutKeepsHijack: a handler can hijack the connection, and no deadline is left on it.TestStallTimeoutLeavesEndedStreams: completed and cancelled streams are not reset afterwards.TestStallTimeoutLeavesPanics: a handler that panics gets its stream reset with no response, as before.TestStallTimeoutRefusedBodyEndsWithHeaders: a body the server refuses, as for a 204, does not count as written.TestStallTimeoutEndsUnreadPRIRequests: HTTP/1 requests whose request line claims HTTP/2.0, pipelined by a client that never reads, get the connection closed.TestStallTimeoutYieldsToWriteWindow: the stall writer is not used while the rolling window is set.TestH2CServerEndsUnreadSocket: the h2c server closes a connection whose client stops reading its socket.TestWriteTimeoutsConfig: defaults, negative values, and whenWriteByteTimeoutapplies.This does not limit how many streams or connections a client opens, and it does not change deployments with
writetimeoutset.