Link to the code that reproduces this issue
https://github.com/dennisat/nextjs-call-stack-size-exceeded-2026-09
To Reproduce
pnpm install
./repro.sh deep # cold start, request /deep/a/b/c/d/e/f/g (8 segments) first
./repro.sh shallow # cold start, request /shallow/a/b/c/d/e/f (7 segments) first
The app is a bare create-next-app with cacheComponents: true, a root layout that wraps children in a trivial
"use client" pass-through component, and two pages that return <p>ok</p>: one at 8 URL segments, one at 7.
Current vs. Expected behavior
./repro.sh deep (Node 20.16.0):
first /deep/a/b/c/d/e/f/g -> 500 RangeError: Maximum call stack size exceeded
second /deep/a/b/c/d/e/f/g -> 500
third /shallow/a/b/c/d/e/f -> 200
fourth /deep/a/b/c/d/e/f/g -> 200 ← works as soon as any shallower route has compiled
./repro.sh shallow: 200 200. The 8-segment route never fails if a shallower route compiled first, and any HMR
recompile also "fixes" it for the rest of the process. rm -rf .next brings it back on the next cold start.
Expected: 200 on every request.
Bisect (each row is one cold start requesting the 8-segment route first):
| Variant |
Codes |
Reproduces |
cacheComponents: true, Turbopack, Node 20.16 (as committed) |
500 500 200 200 |
yes |
cacheComponents removed |
200 200 200 200 |
no |
next dev --webpack |
500 200 200 200 |
yes (2nd request already heals) |
| Deep route with 7 segments |
200 200 200 200 |
no |
| Deep route with 8 segments, other folder names |
500 500 200 200 |
yes |
| Deep route with 9, 10 or 12 segments |
200 200 200 200 |
no |
next@canary (16.4.0-canary.23) |
500 500 200 200 |
yes |
| Node 22.22.2 / 22.5.1 |
200 200 200 200 |
no |
next build && next start |
200 |
no |
No "use client" component in the tree |
200 200 200 200 |
no |
| Client component rendered by the page instead of the layout |
500 500 200 500 |
yes, and never heals |
Notes:
-
Dev only. next build && next start prerenders and serves the route fine.
-
Page content is irrelevant (<p>ok</p>, no imports). Static folders, no dynamic segments, no nested layouts.
-
Exactly 8 segments: 7 passes, 9 and deeper pass too, so this is not plain per-segment stack growth.
-
The terminal only prints at ignore-listed frames; stack.txt in the repo has the 50 frames from the error page.
The overflow lands in React Flight requireModule (loading the client reference) called from Fizz
getComponentNameFromType, under a deep retryNode / renderNodeDestructive / renderElement / finishFunctionComponent recursion:
RangeError: Maximum call stack size exceeded
at requireModule (next/dist/compiled/next-server/app-page-turbo.runtime.dev.js)
at initializeModuleChunk
at readChunk
at getComponentNameFromType
at retryNode
at renderNodeDestructive
at renderNode
at renderChildrenArray
at retryNode
at renderElement
... (retryNode / renderNodeDestructive / renderElement / finishFunctionComponent repeating)
-
Workaround: request any route with ≤ 7 segments first (or trigger any HMR recompile), or use Node 22.
--stack-size is not applicable: Node rejects it in NODE_OPTIONS, which is how next dev passes flags to its
render server.
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 25.6.0 (macOS 26.6.2)
Available memory (MB): 65536
Available CPU cores: 10
Binaries:
Node: 20.16.0
npm: 10.8.1
Yarn: 1.22.22
pnpm: 9.9.0
Relevant Packages:
next: 16.3.3
eslint-config-next: N/A
react: 19.2.8
react-dom: 19.2.8
typescript: 5.9.3
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
cacheComponents, Turbopack, Partial Prerendering (PPR)
Which stage(s) are affected? (Select all that apply)
next dev (local)
Additional context
Also reproduced with [email protected]. Originally hit in a real app (Next 16.3.3, cacheComponents: true, proxy.ts rewrites) with a 27-cold-start bisect showing the same pattern; the minimal repo above removes everything
except the ingredients listed.
Link to the code that reproduces this issue
https://github.com/dennisat/nextjs-call-stack-size-exceeded-2026-09
To Reproduce
The app is a bare
create-next-appwithcacheComponents: true, a root layout that wrapschildrenin a trivial"use client"pass-through component, and two pages that return<p>ok</p>: one at 8 URL segments, one at 7.Current vs. Expected behavior
./repro.sh deep(Node 20.16.0):./repro.sh shallow:200 200. The 8-segment route never fails if a shallower route compiled first, and any HMRrecompile also "fixes" it for the rest of the process.
rm -rf .nextbrings it back on the next cold start.Expected: 200 on every request.
Bisect (each row is one cold start requesting the 8-segment route first):
cacheComponents: true, Turbopack, Node 20.16 (as committed)cacheComponentsremovednext dev --webpacknext@canary(16.4.0-canary.23)next build && next start"use client"component in the treeNotes:
Dev only.
next build && next startprerenders and serves the route fine.Page content is irrelevant (
<p>ok</p>, no imports). Static folders, no dynamic segments, no nested layouts.Exactly 8 segments: 7 passes, 9 and deeper pass too, so this is not plain per-segment stack growth.
The terminal only prints
at ignore-listed frames;stack.txtin the repo has the 50 frames from the error page.The overflow lands in React Flight
requireModule(loading the client reference) called from FizzgetComponentNameFromType, under a deepretryNode / renderNodeDestructive / renderElement / finishFunctionComponentrecursion:Workaround: request any route with ≤ 7 segments first (or trigger any HMR recompile), or use Node 22.
--stack-sizeis not applicable: Node rejects it inNODE_OPTIONS, which is hownext devpasses flags to itsrender server.
Provide environment information
Which area(s) are affected? (Select all that apply)
cacheComponents, Turbopack, Partial Prerendering (PPR)
Which stage(s) are affected? (Select all that apply)
next dev (local)
Additional context
Also reproduced with
[email protected]. Originally hit in a real app (Next 16.3.3,cacheComponents: true,proxy.tsrewrites) with a 27-cold-start bisect showing the same pattern; the minimal repo above removes everythingexcept the ingredients listed.