mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[GH-ISSUE #241] RSC serialization fails with null-prototype params from matchPattern() #59
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#59
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 @gagipro on GitHub (Mar 3, 2026).
Original GitHub issue: https://github.com/cloudflare/vinext/issues/241
Bug Description
When a Next.js app uses dynamic route params (e.g.
/dashboards/[id]), the RSC serializer throws an error becausematchPattern()internally usesObject.create(null), producing objects with a null prototype.The current code in
app-dev-server.tsdoes:This creates a Promise-like object that the RSC serializer detects as a thenable. It resolves the thenable, gets back the original null-prototype object, and throws because it cannot serialize objects without
Object.prototype.Root Cause
Two issues compounding:
matchPattern()returnsObject.create(null)objects (null prototype)Object.assign(Promise.resolve(params), params)produces a thenable that the RSC serializer resolves back to the original null-prototype objectFix
Replace with a plain spread that normalizes the prototype:
Since
await plainObjectreturns the object itself in JS, a.then()method is not needed — React 19 / Next.js 16 components canawaitplain objects.Files Changed
packages/vinext/src/server/app-dev-server.tsmakeThenableParams(), replaced 6 occurrences ofObject.assign(Promise.resolve(...), ...). Changedcredentials: "include"tocredentials: "same-origin"on 4 fetch calls to match Next.js behavior.packages/vinext/src/shims/metadata.tsxmakeThenableParams()pattern, replaced 3 occurrences inresolveModuleViewportandresolveModuleMetadata.packages/vinext/src/index.tsfindReactServerPackages()to auto-exclude packages withreact-serverexport condition from RSCoptimizeDeps(prevents pre-bundling issues).Reproduction
/dashboards/[id])NODE_ENV=production)Environment