Apply the webFetch timeout to the response body - #102
Open
RenKoya1 wants to merge 1 commit into
Open
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
The 30s timeout was cleared as soon as fetch() resolved, which is when headers arrive. A response whose body then stalled was read with no deadline at all, so the agent's webFetch tool call could hang until the Worker itself gave out. Keep the timer armed across the body read and clear it in one finally, so an abort mid-body surfaces as the same "Fetch timed out" error.
RenKoya1
force-pushed
the
fix/webfetch-body-timeout
branch
from
August 9, 2026 17:09
4c064b0 to
7de89a2
Compare
Author
|
I have read the CLA Document and I hereby sign the CLA |
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.
webFetcharms a 30s abort timer, but clears it in thefinallyof thefetch()call — which resolves as soon as the response headers arrive. The body read that follows therefore runs with no deadline: a response whose headers arrive promptly and whose body then stalls holds the agent'swebFetchtool call open until the Worker itself gives out.HARD_MAX_BYTESbounds the size, not the time.The change keeps the timer armed across the body read and clears it in a single
finally, so an abort mid-body surfaces as the sameFetch timed out after 30000mserror the header path already produces. The diff looks larger than it is — most of it is the existing final-URL / Content-Signal /readBodyCappedblock moving inside thetryunchanged.Verification
Added a regression test that stubs
fetchwith a body that yields one chunk and then only ends on abort, and advances fake timers past the deadline.AbortSignalis still un-aborted after 60 simulated seconds.webFetchrejects withFetch timed out after 30000ms.pnpm exec tsc --noEmitclean,workshop-backendsuite 280/280 passing, oxlint reports nothing new.