fix(react-router): Carry multi-byte UTF-8 across SSR stream chunk boundaries - #23307
Open
logaretm wants to merge 2 commits into
Open
fix(react-router): Carry multi-byte UTF-8 across SSR stream chunk boundaries#23307logaretm wants to merge 2 commits into
logaretm wants to merge 2 commits into
Conversation
…unks Adds regression tests for `injectTraceMetaTags` (Cloudflare) and `getMetaTagTransformer` (Node) that split a multi-byte character across stream chunk boundaries. These fail against the current per-chunk, non-streaming decode, which flushes the split character as U+FFFD.
…ndaries `injectTraceMetaTags` and `getMetaTagTransformer` decoded each stream chunk with a fresh, non-streaming decoder. A multi-byte character split across a chunk boundary was flushed as two U+FFFD and written into the response, breaking React hydration (#418) and wiping the injected trace meta tags on re-render. Use a single hoisted `TextDecoder` with `{ stream: true }` so an incomplete trailing sequence is carried into the next chunk, matching the pattern already used in the Astro and SolidStart middleware.
Member
Author
|
bugbot run |
Contributor
size-limit report 📦
|
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit e920ab3. Configure here.
logaretm
marked this pull request as ready for review
August 11, 2026 18:30
logaretm
requested review from
chargome and
s1gr1d
and removed request for
a team
August 11, 2026 18:30
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 the UTF-8 corruption in #23305: a multi-byte character split across an SSR stream chunk boundary got replaced by two U+FFFD, breaking React hydration (#418) and wiping the injected trace meta tags on re-render.
Both injectors decoded each chunk with a fresh, non-streaming decoder, so a split character's trailing bytes were flushed as U+FFFD instead of carried over. Fixed by using one hoisted
TextDecoderwith{ stream: true }, matching what the Astro and SolidStart middleware already do.Tests are deterministic, since the bug only fires when a char lands exactly on a chunk boundary and an e2e sweep would just flake.
closes #23305