fix: clone Request inputs so retries do not reuse a consumed body - #197
Open
pouyashahrdami wants to merge 1 commit into
Open
fix: clone Request inputs so retries do not reuse a consumed body#197pouyashahrdami wants to merge 1 commit into
pouyashahrdami wants to merge 1 commit into
Conversation
fetchWithRetry sent the same Request instance on every attempt, but the first attempt consumes the body stream, so every retry of a POST/PUT with a body failed with "Body has already been used". This broke retries for all execute-tool API calls proxied through GlobalOutbound: a 429 slept through the backoff delays and returned the original 429 anyway, and a network error surfaced a misleading TypeError instead of retrying. Send a clone on every attempt that can still be retried and let the final attempt consume the original.
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 #196
fetchWithRetrysends the sameRequestinstance on every attempt, but the first attempt consumes the body stream — so every retry of a body-carrying request (POST/PUT/PATCH) fails withBody has already been used. This breaks retry for allexecutetool API calls proxied throughGlobalOutbound: after a 429 the loop sleeps through every backoff delay and returns the original 429 anyway, and after a network error it surfaces a misleading TypeError instead of retrying.Fix: send a clone on every attempt that can still be retried; the final attempt consumes the original, so no cloned body is left unconsumed.
Tests: three new cases covering retry-after-429, retry-after-network-error, and final-attempt identity — all reproduce the failure on
main(existing tests only used string URLs, which is why this was never caught).npm run checkpasses.