fix(fetch): preserve error code in decompression pipeline for retry logic#40946
Open
SebTardif wants to merge 1 commit into
Open
fix(fetch): preserve error code in decompression pipeline for retry logic#40946SebTardif wants to merge 1 commit into
SebTardif wants to merge 1 commit into
Conversation
yury-s
reviewed
May 22, 2026
Member
yury-s
left a comment
There was a problem hiding this comment.
The change looks good, but please add a test.
…ogic When a compressed HTTP response (gzip/br/deflate) encounters a network error like ECONNRESET during body streaming, the pipeline error callback and body error handler were wrapping the original error in a new Error, destroying the .code property. The retry logic in _sendRequestWithRetries checks e.code !== 'ECONNRESET' to decide whether to retry, so retries never happened for compressed responses. Fix: check if the error is a network error (ECONNRESET, EPIPE, ECONNABORTED) and pass it through unwrapped so the retry logic can see the code. Only wrap non-network errors as decompression failures.
ec419c9 to
7de5f9e
Compare
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.
What this PR does
Fixes
maxRetriesbeing silently broken for compressed HTTP responses.In
packages/playwright-core/src/server/fetch.ts, the decompression pipeline error callback wraps all errors innew Error(...), destroying the.codeproperty. The retry logic in_sendRequestWithRetriescheckse.code !== 'ECONNRESET'to decide whether to retry. Since the wrapped error has no.code, retries never happen for compressed responses (the vast majority of real-world HTTP traffic, sinceaccept-encoding: gzip,deflate,bris sent by default).Fix: Added
isNetworkConnectionError()helper that checks forECONNRESET,EPIPE,ECONNABORTED. Network errors are passed through unwrapped to preserve.code; only actual decompression failures get wrapped.AI Disclosure
Developed with AI assistance (Grok by xAI) in a human-in-the-loop workflow. All code reviewed and verified by the human author.