Repository navigation
Conversation
uhvesta
force-pushed
the
fix/raw-handler-response-body-timeout
branch
from
September 23, 2026 06:34
5d84fae to
a57b8ad
Compare
RawHttpClientBase disables HttpClient.Timeout and SendTimeout stops at the response headers, so a body that stalls after the headers (seen on acquirejob) hangs the listener. Give buffered bodies an idle timeout of SendTimeout, applied after the retry handler has seen the status.
uhvesta
force-pushed
the
fix/raw-handler-response-body-timeout
branch
from
September 23, 2026 22:33
28d37c4 to
3567f0d
Compare
uhvesta
marked this pull request as ready for review
September 23, 2026 22:49
Contributor
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
Direct handler users need supported completion-option propagation and test coverage.
Review effort: Lite
Findings: None
What changed in this PR
Adds idle timeouts for buffered response-body reads while preserving streaming and retry behavior.
Changes:
- Propagates
HttpCompletionOptionthrough raw clients. - Wraps buffered response content with resettable timeouts.
- Adds loopback tests for stalls, retries, cancellation, and streaming.
| File | Summary |
|---|---|
src/Test/L0/Sdk/RawHttpMessageHandlerL0.cs |
Tests timeout and compatibility behavior. |
src/Sdk/WebApi/WebApi/RawHttpClientBase.cs |
Passes completion options to handlers. |
src/Sdk/Common/Common/RawHttpMessageHandler.cs |
Implements response-body timeout handling. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Addresses Copilot review feedback that the fallback for requests sent outside RawHttpClientBase had no test coverage.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4668
Fixes #4703
Problem
RawHttpClientBaseturns offHttpClient.Timeout, andRawHttpMessageHandler'sSendTimeoutonly covers the request until the response headers arrive. If a server sends the headers and then stops sending the body, the read waits forever unless the caller cancels.That's what happens in #4668 and #4703. After
Acknowledging runner request, the listener POSTs toacquirejob, the body stalls after the headers, and the listener's main loop blocks on that read. Nothing else in the runner can cancel it, because session restarts, self-updates and ephemeral shutdown all run on that same loop, so the runner never takes another job or exits. About 10 minutes later GitHub fails the job with "The self-hosted runner lost communication with the server", but the process still looks healthy and someone has to kill it by hand. Under ARC, each stuck pod keeps taking up a runner slot.Approach
Response bodies have never timed out, and something may rely on that (a large or slow response that takes longer than
SendTimeoutto arrive), so this adds an idle timeout rather than a deadline on the whole body:SendTimeoutwith no data. Each read restarts the timer, so a slow body that keeps arriving still completes. A stall fails with the sameTimeoutExceptionas a header timeout.HttpClientbuffers the body, afterVssHttpRetryMessageHandlerhas acted on the status. Reading the body inside the handler instead would put body errors inside the retry loop and change which requests get retried.ResponseHeadersReadrequests (such as results uploads) aren't buffered and get no body timeout.RawHttpClientBasenow passes the completion option to the handler so it can tell.For
acquirejob, that means aTimeoutExceptionafter 100 seconds with no data by default (GITHUB_ACTIONS_RUNNER_HTTP_TIMEOUTallows 100–1200).RunServertries up to 5 times, then the listener goes back to polling.Behavior
mainTimeoutExceptionafterSendTimeoutwith no dataCaller cancellation,
ResponseHeadersReadstreaming and a disabledSendTimeoutbehave as before.Testing
The new
RawHttpMessageHandlerL0tests run a realSocketsHttpHandleragainst a loopback TCP server, so they go through the actual HTTP stack without network access. The stall tests hang onmain(a watchdog turns the hang into a failure) and pass here. The rest pass on both and cover the behavior above that shouldn't change.