mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[GH-ISSUE #676] Non-ASCII dynamic route params crash RSC streaming with ByteString error #145
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#145
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @seoJing on GitHub (Mar 24, 2026).
Original GitHub issue: https://github.com/cloudflare/vinext/issues/676
Non-ASCII dynamic route params crash RSC streaming with ByteString error
Bug Description
When a dynamic route parameter contains non-ASCII characters (e.g., Korean, Japanese, Chinese), RSC (React Server Component) streaming requests fail with a 500 Internal Server Error. Direct URL access (full SSR) works correctly, but client-side navigation (
.rscrequests) crashes.Root Cause
In
src/server/app-page-response.ts, thebuildAppPageRscResponse()function serializes route params directly into an HTTP header:Per the Fetch specification,
Headers.set()requires the value to be a ByteString (each character code ≤ 255). When params contain non-ASCII characters,JSON.stringify()preserves them as-is, causing aTypeError.Reproduction
app/blog/[...slug]/page.tsx<Link>to/blog/frontend/hooks/useState-완전정복).rscrequest fails with:Verification: index 38 of
JSON.stringify({"slug":["frontend","hooks","useState-완전정복"]})is완(U+C644 = 50756), confirming the exact failure point.Minimal reproduction
Impact
buildAppPageHtmlResponse()does not setX-Vinext-ParamsbuildAppPageRscResponse()crashesThis affects any locale that uses non-ASCII characters in URL slugs (Korean, Japanese, Chinese, Arabic, Cyrillic, etc.).
Suggested Fix
Percent-encode the JSON string before setting the header:
The consumer side would need a corresponding
decodeURIComponent()call. This is the same approach Next.js uses for non-ASCII values in HTTP headers (ref: vercel/next.js#27003).Environment
Additional Context
I discovered this while building a Korean-language MDX blog. The blog list page (
/blog) triggers client-side prefetch/navigation for each post link, and all non-ASCII slugs fail simultaneously. I'd be happy to submit a PR with the fix if the suggested approach looks right.