Skip to content

Dev-only RangeError in App Router async traversal when large Prisma MSSQL query resolves (~10k rows) #87772

@aliameur

Description

@aliameur

Link to the code that reproduces this issue

https://github.com/aliameur/next-prisma-rangeerror-repro

To Reproduce

  1. Install deps (pnpm install)
  2. Create mssql db (docker compose up -d)
  3. Push prisma schema and seed (pnpm prisma:push && pnpm prisma:seed)
  4. Start the application in development (pnpm dev)
  5. Visit / or /full to reproduce the error

Current vs. Expected behavior

When resolving a Prisma MSSQL query returning ~10,000 rows inside a Server Component, next dev crashes with a stack overflow inside the App Router dev runtime.
I expect the page to render correctly, instead it gives this error

RangeError: Maximum call stack size exceeded
    at Map.has (<anonymous>)
⨯ unhandledRejection: RangeError: Maximum call stack size exceeded
    at Map.has (<anonymous>)
⨯ unhandledRejection:  RangeError: Maximum call stack size exceeded
    at Map.has (<anonymous>)

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.0.0: Wed Sep 17 21:35:32 PDT 2025; root:xnu-12377.1.9~141/RELEASE_ARM64_T6020
  Available memory (MB): 16384
  Available CPU cores: 10
Binaries:
  Node: 22.18.0
  npm: 10.9.3
  Yarn: 1.22.22
  pnpm: 10.11.0
Relevant Packages:
  next: 16.1.1 // Latest available version is detected (16.1.1).
  eslint-config-next: N/A
  react: 19.2.3
  react-dom: 19.2.3
  typescript: 5.9.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Error Handling, Webpack, Turbopack, Runtime

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

I tested my repro against different canary versions, and this behaviour was introduced in "v15.4.2-canary.17", "v15.4.2-canary.16" works fine

Additional context

  • Reproducible locally using next dev on macOS (and Docker MSSQL backend)
  • Deployment environment doesn’t matter, since the issue only happens in the development App Router runtime
  • Works correctly in:
    • next build && next start (production)
    • API routes
    • standalone Node scripts
  • Issue is database-driver-specific:
    • PostgreSQL Prisma adapter: works fine
    • MSSQL Prisma adapter: triggers the crash
  • Regression observed:
    • v15.4.2-canary.16 works fine
    • v15.4.2-canary.17 introduces the recursion failure in visitAsyncNode
    • Current stable also exhibits the bug
  • Verified using Chrome inspector and stack traces:
    • Infinite recursion happens inside the dev runtime file: next/dist/compiled/next-server/app-page-turbo.runtime.dev.js
    • Specifically within the function named visitAsyncNode

Based on stepping through the dev runtime with Chrome inspector, the recursion loop occurs before any data is rendered, while dev traversal is visiting async nodes created from the MSSQL request resolution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Error HandlingRelated to handling errors (e.g., error.tsx, global-error.tsx).RuntimeRelated to Node.js or Edge Runtime with Next.js.TurbopackRelated to Turbopack with Next.js.WebpackRelated to Webpack with Next.js.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions