fix(retry): make RetryController rawHeaders/rawTrailers writable - #5766
Closed
pacocartones wants to merge 1 commit into
Closed
fix(retry): make RetryController rawHeaders/rawTrailers writable#5766pacocartones wants to merge 1 commit into
pacocartones wants to merge 1 commit into
Conversation
…roxy The RetryController proxy handed to downstream handlers exposed rawHeaders and rawTrailers as getter-only accessors. Interceptors composed after retry (decompress, cache) reassign controller.rawHeaders to strip headers they have consumed, so the assignment threw "Cannot set property rawHeaders of RetryController which has only a getter" and the request failed with a TypeError. Add setters that forward the write to the active connection's controller, matching the transparent-proxy contract and the writable rawHeaders/rawTrailers of RequestController. Fixes: nodejs#5726
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5766 +/- ##
==========================================
- Coverage 93.50% 93.50% -0.01%
==========================================
Files 110 110
Lines 39072 39074 +2
==========================================
+ Hits 36534 36535 +1
- Misses 2538 2539 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Member
|
Sorry, can you rebase? |
Contributor
Author
|
Closing this — it turned out to duplicate #5727 (by @official-burak), which landed the same |
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 #5726.
Problem
RetryController(lib/handler/retry-handler.js) exposedrawHeadersandrawTrailersas getter-only accessors, but the realRequestController(lib/core/request.js) declares them as writable data properties. Interceptors composed downstream of retry legitimately reassign them — the decompress interceptor doescontroller.rawHeaders = filteredHeaders(to stripcontent-encoding/content-length), and the cache interceptor does the same. When retry sits ahead of decompress, the interceptor gets the retry proxy and the assignment throws:TypeError: Cannot set property rawHeaders of #<RetryController> which has only a getterrawTrailershad the identical latent defect (assigned byrequest.jsandmock-utils.js).Fix
Add forwarding setters to the proxy, mirroring the existing getters and the writable fields of the real controller — making the proxy transparent for writes as it already is for reads. Consistent with the proxy's design ("always forwards to the controller of the currently active connection").
Test
test/retry-handler-controller-proxy.js— unit: forwardsrawHeaders/rawTrailerswrites (RED: getter-only TypeError; GREEN: forwarded).test/interceptors/decompress.js— end-to-end: retry composed before decompress (RED at HEAD; GREEN with fix).decompress 28/28, retry-handler/retry-agent suites,
npm run lint— all green.