Link to the code that reproduces this issue
https://github.com/Adophlidu/next-dpl-undefined-repro
To Reproduce
Skew Protection asset suffixes are wired up by the Vercel build environment, so this requires deploying to Vercel (any plan — reproduces on a Hobby project with no special settings). It does not reproduce locally; full steps are in the repro README.
- Deploy the repro (one static page
/, one force-dynamic page /dyn, deploymentId: process.env.VERCEL_DEPLOYMENT_ID in next.config.mjs): npx vercel deploy --prod
- Compare the served HTML:
curl -s https://<deployment-url>/ | grep -o 'dpl=[A-Za-z0-9_]*' | sort | uniq -c
curl -s https://<deployment-url>/dyn | grep -o 'dpl=[A-Za-z0-9_]*' | sort | uniq -c
Observed (next 16.2.6, also 16.2.7; Vercel CLI 54.18.7):
/ -> 20 dpl=dpl_9yDhqpKfbm76Rb5knDDfGm9WX5HR # static: all correct
/dyn -> 10 dpl=dpl_9yDhqpKfbm76Rb5knDDfGm9WX5HR # dynamic: mixed
12 dpl=undefined
Current vs. Expected behavior
Current:
On dynamically rendered routes, the same chunk is referenced twice in one document — <script src=".../chunk.js?dpl=dpl_xxx" async> (entry scripts, correct) and <script src=".../chunk.js?dpl=undefined" async> (manifest-driven flight/preinit refs) — so browsers download every chunk twice. The RSC flight payload also carries the dpl=undefined URLs, so lazily loaded chunks use the broken suffix as well: those requests are not pinned by Skew Protection, and the ?dpl=undefined query never changes across deployments, defeating the cache-busting semantics. Statically prerendered routes emit correct suffixes only.
On a mid-sized production app this doubled 67 chunks (~1.9MB extra compressed transfer and ~80 extra requests per cold visit), and left ~1250 dpl=undefined chunk references in the flight payload of a single page.
The mechanism appears to be the same auto-enable reported in #94734 for the prebuilt flow: when Vercel runs next build (hasNextSupport true, NEXT_DEPLOYMENT_ID present in the build env), packages/next/src/server/config.ts silently sets experimental.runtimeServerDeploymentId = true, deferring chunk-URL deployment ids to a runtime process.env.NEXT_DEPLOYMENT_ID / globalThis.NEXT_DEPLOYMENT_ID read. On the deployed serverless functions' dynamic-render path that value resolves to undefined and is stringified straight into the URL (no guard on this path, unlike getDeploymentIdQuery).
Notes from debugging (details in the repro README):
next build + next start locally: /dyn is all-correct — the auto-enable never happens without hasNextSupport.
vercel build locally: zero dpl=undefined anywhere in .vercel/output, so the broken value is produced at request time, not baked.
- A probe route on the deployed app shows
process.env.VERCEL_DEPLOYMENT_ID set, while globalThis.NEXT_DEPLOYMENT_ID and globalThis.NEXT_CLIENT_ASSET_SUFFIX are null in the function runtime.
- Setting the env var or the globals from
instrumentation.ts does not reach the rendering context.
experimental.useSkewCookie: true sets the __vdpl cookie but does not remove the ?dpl= suffixes; the undefined variants remain.
Expected:
Dynamic and static routes should emit the same, correct ?dpl= suffix exactly once per chunk — or no suffix at all — but never a stringified undefined, and never both variants of the same chunk in one document.
Verified workaround: experimental: { runtimeServerDeploymentId: false } — with it, /dyn emits all-correct suffixes (20 dpl=dpl_xxx, 0 undefined) and the x-nextjs-deployment-id header on RSC responses stays intact.
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 23.3.0
Binaries:
Node: 24.13.0
npm: 11.6.2
Relevant Packages:
next: 16.2.6 (also reproduced on 16.2.7; 16.2.8-16.2.10 contain no code changes)
react: 19.2.7
react-dom: 19.2.7
typescript: 6.0.3
Next.js Config:
output: N/A
Deployment: Vercel (standard build — Vercel runs `next build`; NOT the prebuilt flow)
Which area(s) are affected? (Select all that apply)
Runtime, Turbopack
Which stage(s) are affected? (Select all that apply)
Vercel (Deployed)
Link to the code that reproduces this issue
https://github.com/Adophlidu/next-dpl-undefined-repro
To Reproduce
Skew Protection asset suffixes are wired up by the Vercel build environment, so this requires deploying to Vercel (any plan — reproduces on a Hobby project with no special settings). It does not reproduce locally; full steps are in the repro README.
/, oneforce-dynamicpage/dyn,deploymentId: process.env.VERCEL_DEPLOYMENT_IDinnext.config.mjs):npx vercel deploy --prodObserved (next 16.2.6, also 16.2.7; Vercel CLI 54.18.7):
Current vs. Expected behavior
Current:
On dynamically rendered routes, the same chunk is referenced twice in one document —
<script src=".../chunk.js?dpl=dpl_xxx" async>(entry scripts, correct) and<script src=".../chunk.js?dpl=undefined" async>(manifest-driven flight/preinit refs) — so browsers download every chunk twice. The RSC flight payload also carries thedpl=undefinedURLs, so lazily loaded chunks use the broken suffix as well: those requests are not pinned by Skew Protection, and the?dpl=undefinedquery never changes across deployments, defeating the cache-busting semantics. Statically prerendered routes emit correct suffixes only.On a mid-sized production app this doubled 67 chunks (~1.9MB extra compressed transfer and ~80 extra requests per cold visit), and left ~1250
dpl=undefinedchunk references in the flight payload of a single page.The mechanism appears to be the same auto-enable reported in #94734 for the prebuilt flow: when Vercel runs
next build(hasNextSupporttrue,NEXT_DEPLOYMENT_IDpresent in the build env),packages/next/src/server/config.tssilently setsexperimental.runtimeServerDeploymentId = true, deferring chunk-URL deployment ids to a runtimeprocess.env.NEXT_DEPLOYMENT_ID/globalThis.NEXT_DEPLOYMENT_IDread. On the deployed serverless functions' dynamic-render path that value resolves toundefinedand is stringified straight into the URL (no guard on this path, unlikegetDeploymentIdQuery).Notes from debugging (details in the repro README):
next build+next startlocally:/dynis all-correct — the auto-enable never happens withouthasNextSupport.vercel buildlocally: zerodpl=undefinedanywhere in.vercel/output, so the broken value is produced at request time, not baked.process.env.VERCEL_DEPLOYMENT_IDset, whileglobalThis.NEXT_DEPLOYMENT_IDandglobalThis.NEXT_CLIENT_ASSET_SUFFIXarenullin the function runtime.instrumentation.tsdoes not reach the rendering context.experimental.useSkewCookie: truesets the__vdplcookie but does not remove the?dpl=suffixes; theundefinedvariants remain.Expected:
Dynamic and static routes should emit the same, correct
?dpl=suffix exactly once per chunk — or no suffix at all — but never a stringifiedundefined, and never both variants of the same chunk in one document.Verified workaround:
experimental: { runtimeServerDeploymentId: false }— with it,/dynemits all-correct suffixes (20 dpl=dpl_xxx, 0 undefined) and thex-nextjs-deployment-idheader on RSC responses stays intact.Provide environment information
Which area(s) are affected? (Select all that apply)
Runtime, Turbopack
Which stage(s) are affected? (Select all that apply)
Vercel (Deployed)