mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #242] [CLOSED] fix: RSC serialization with null-prototype params from matchPattern() #414
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#414
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?
📋 Pull Request Information
Original PR: https://github.com/cloudflare/vinext/pull/242
Author: @gagipro
Created: 3/3/2026
Status: ❌ Closed
Base:
main← Head:test/cherry-pick-rsc-fixes📝 Commits (5)
ab2f9b1fix: auto-exclude react-server packages from RSC optimizeDeps70cd2fcfix: use credentials 'same-origin' (not 'include') to match Next.js behavior32787d7fix: use plain-object thenable for params/searchParams to fix RSC serializationa25fcfafix: apply makeThenableParams to metadata.tsx (resolveModuleViewport + resolveModuleMetadata)eb2539bfix: use Promise.resolve({...obj}) for RSC-safe params📊 Changes
8 files changed (+1129 additions, -263 deletions)
View changed files
📝
.gitignore(+1 -0)📝
packages/vinext/README.md(+680 -1)📝
packages/vinext/src/index.ts(+103 -1)📝
packages/vinext/src/server/app-dev-server.ts(+29 -9)📝
packages/vinext/src/shims/link.tsx(+1 -1)📝
packages/vinext/src/shims/metadata.tsx(+12 -3)📝
packages/vinext/src/shims/navigation.ts(+1 -1)📝
tests/fixtures/pages-basic/dist/server/entry.js(+302 -247)📄 Description
Fixes #241
Summary
matchPattern()returns objects created withObject.create(null)(null prototype). The current code wraps these inObject.assign(Promise.resolve(params), params), creating a thenable that the RSC serializer resolves back to the original null-prototype object — which it cannot serialize, causing 500 errors on all dynamic routes.Changes
packages/vinext/src/server/app-dev-server.tsmakeThenableParams(obj)— returns{ ...obj }to normalize the prototypeObject.assign(Promise.resolve(...), ...)withmakeThenableParams(...)credentials: "include"→credentials: "same-origin"on 4 fetch calls (RSC payload, server actions, navigation, HMR) to match Next.js behaviorpackages/vinext/src/shims/metadata.tsxmakeThenableParams()helperresolveModuleViewport()andresolveModuleMetadata()packages/vinext/src/index.tsfindReactServerPackages()to auto-exclude packages withreact-serverexport condition from RSCoptimizeDeps(prevents pre-bundling issues with packages likeswr)Why
{ ...obj }worksSince
await plainObjectreturns the object itself in JavaScript, a.then()method is not needed. React 19 / Next.js 16 components canawaitplain objects just fine. The spread simply normalizes the null prototype toObject.prototype, which the RSC serializer accepts.Testing
Tested with a production Next.js 16 / React 19 app with:
/dashboards/[id])generateMetadata()with async paramsNODE_ENV=productionAll pages render correctly on both dev and production builds.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.