fix: preserve utf8 decoding across response chunks#5414
Open
pupuking723 wants to merge 2 commits into
Open
Conversation
Signed-off-by: 王胜 <2318857637@qq.com>
metcoder95
approved these changes
Jun 12, 2026
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5414 +/- ##
==========================================
- Coverage 93.25% 93.24% -0.02%
==========================================
Files 110 110
Lines 36825 36868 +43
==========================================
+ Hits 34340 34376 +36
- Misses 2485 2492 +7 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
mcollina
requested changes
Jun 15, 2026
mcollina
left a comment
Member
There was a problem hiding this comment.
I'm relatively certain that Readable implements this logic. I think the problem is in the override of setEncoding, we should also call super.setEncoding
Signed-off-by: 王胜 <2318857637@qq.com>
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.
This relates to...
Fixes #5002
Rationale
BodyReadable#setEncoding() only stored the encoding on the readable state. That made streamed consumers decode each buffered chunk independently, so an incomplete UTF-8 sequence at a response chunk boundary produced replacement characters.
The internal body consumers still need raw Buffer chunks so body.text() and body.json() can aggregate and decode the full payload.
Changes
Features
N/A
Bug Fixes
Breaking Changes and Deprecations
N/A
Status
Verification:
Note: npm ci --ignore-scripts was used locally because npm install exited with "Exit handler never called!" after dependency extraction. The test/lint commands above were run against the installed dependency tree. Local Node.js is v22.17.0 while the package currently requires >=22.19.0.