prisma / prisma

Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, MongoDB and CockroachDB
https://www.prisma.io
Apache License 2.0
39.41k stars 1.54k forks source link

Next.js build: `RangeError: Maximum call stack size exceeded` in `typescript.js` when using TypeScript 5.1.3 #19715

Open kamil-wsiiz opened 1 year ago

kamil-wsiiz commented 1 year ago

Bug description

While using Prisma and Mongoose during the execution of "npm run build", I'm receiving an error even with the simplest possible schema creation code.

> Build error occurred
RangeError: Maximum call stack size exceeded
    at couldContainTypeVariables (/node_modules/typescript/lib/typescript.js:65159:39)
    at inferFromTypes (/node_modules/typescript/lib/typescript.js:65453:14)
    at inferFromTypes (/node_modules/typescript/lib/typescript.js:65459:11)
    at inferFromTypes (/node_modules/typescript/lib/typescript.js:65459:11)
    at inferFromTypes (/node_modules/typescript/lib/typescript.js:65459:11)
    at inferFromTypes (/node_modules/typescript/lib/typescript.js:65459:11)
    at inferFromTypes (/node_modules/typescript/lib/typescript.js:65459:11)
    at inferFromTypes (/node_modules/typescript/lib/typescript.js:65459:11)
    at inferFromTypes (/node_modules/typescript/lib/typescript.js:65459:11)
    at inferFromTypes (/node_modules/typescript/lib/typescript.js:65459:11) {
  type: 'RangeError'
}

After several hours of searching for the problem in a larger project, I have established several facts:

Has anyone encountered a similar problem and can suggest how to solve it?

How to reproduce

  1. npx create-next-app@latest
  2. Change into created folder
  3. npm install prisma --save-dev
  4. npm install @prisma/client mongoose
  5. npx prisma init --datasource-provider sqlite
  6. Add Test schema
    model Test {
      id    Int     @id @default(autoincrement())
      name  String
    }
  7. npx prisma generate
  8. Create lib/test.ts file with a content (it is the example code that illustrates the problem):

    import { PrismaClient } from '@prisma/client'
    import mongoose from 'mongoose';
    
    new PrismaClient().test.create({
      data: {
        name: "test",
      },
    });
    
    new mongoose.Schema({
      site: String
    });
  9. npm run build

Expected behavior

Error-free project build.

Prisma information

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "sqlite"
  url      = env("DATABASE_URL")
}

model Test {
  id    Int     @id @default(autoincrement())
  name  String
}
new PrismaClient().test.create({
  data: {
    name: "test",
  },
});

Environment & setup

Prisma Version

prisma                  : 4.15.0
@prisma/client          : 4.15.0
Current platform        : darwin
Query Engine (Node-API) : libquery-engine 8fbc245156db7124f997f4cecdd8d1219e360944 (at node_modules/@prisma/engines/libquery_engine-darwin.dylib.node)
Migration Engine        : migration-engine-cli 8fbc245156db7124f997f4cecdd8d1219e360944 (at node_modules/@prisma/engines/migration-engine-darwin)
Format Wasm             : @prisma/prisma-fmt-wasm 4.15.0-28.8fbc245156db7124f997f4cecdd8d1219e360944
Default Engines Hash    : 8fbc245156db7124f997f4cecdd8d1219e360944
Studio                  : 0.484.0
yutakobayashidev commented 1 year ago

I am using MySQL and got the same error

https://github.com/yutakobayashidev/capitalens/commit/ac1c66db212f80b76459d4f9c39c72926da1a767

janpio commented 1 year ago

What exactly does that commit signify @yutakobayashidev - did you upgrade these dependencies - probably most important the TS version - and that led to a Server Component error to appear in your project?

janpio commented 1 year ago

Thanks for the nice reproduction steps, I could easily by following them:

PS C:\Users\Jan\Documents\throwaway\19715\my-app> npm run build

> my-app@0.1.0 build
> next build

- info Loaded env from C:\Users\Jan\Documents\throwaway\19715\my-app\.env
- info Creating an optimized production build
- info Compiled successfully

> Build error occurred
RangeError: Maximum call stack size exceeded
    at couldContainTypeVariables (C:\Users\Jan\Documents\throwaway\19715\my-app\node_modules\typescript\lib\typescript.js:65159:39)
    at inferFromTypes (C:\Users\Jan\Documents\throwaway\19715\my-app\node_modules\typescript\lib\typescript.js:65453:14)
    at inferFromTypes (C:\Users\Jan\Documents\throwaway\19715\my-app\node_modules\typescript\lib\typescript.js:65459:11)
    at inferFromTypes (C:\Users\Jan\Documents\throwaway\19715\my-app\node_modules\typescript\lib\typescript.js:65459:11)
    at inferFromTypes (C:\Users\Jan\Documents\throwaway\19715\my-app\node_modules\typescript\lib\typescript.js:65459:11)
    at inferFromTypes (C:\Users\Jan\Documents\throwaway\19715\my-app\node_modules\typescript\lib\typescript.js:65459:11)
    at inferFromTypes (C:\Users\Jan\Documents\throwaway\19715\my-app\node_modules\typescript\lib\typescript.js:65459:11)
    at inferFromTypes (C:\Users\Jan\Documents\throwaway\19715\my-app\node_modules\typescript\lib\typescript.js:65459:11)
    at inferFromTypes (C:\Users\Jan\Documents\throwaway\19715\my-app\node_modules\typescript\lib\typescript.js:65459:11)
    at inferFromTypes (C:\Users\Jan\Documents\throwaway\19715\my-app\node_modules\typescript\lib\typescript.js:65459:11) {
  type: 'RangeError'
}
- info Linting and checking validity of types .
janpio commented 1 year ago

A temporary workaround might be to downgrade to the previous typescript version: npm install typescript@5.0.4

PS C:\Users\Jan\Documents\throwaway\19715\my-app> npx next build
- info Loaded env from C:\Users\Jan\Documents\throwaway\19715\my-app\.env
- info Creating an optimized production build
- info Compiled successfully
- info Linting and checking validity of types
- info Collecting page data
- info Generating static pages (4/4)
- info Finalizing page optimization

Route (app)                                Size     First Load JS
┌ ○ /                                      4.78 kB          82 kB
└ ○ /favicon.ico                           0 B                0 B
+ First Load JS shared by all              77.3 kB
  ├ chunks/488-2398932694129a7b.js         24.9 kB
  ├ chunks/bce60fc1-49ee79ad31766ac6.js    50.5 kB
  ├ chunks/main-app-297b12279ce3dd6b.js    215 B
  └ chunks/webpack-737972036df45a17.js     1.64 kB

Route (pages)                              Size     First Load JS
─ ○ /404                                   181 B          74.7 kB
+ First Load JS shared by all              74.5 kB
  ├ chunks/framework-8883d1e9be70c3da.js   45.1 kB
  ├ chunks/main-66891548548be155.js        27.6 kB
  ├ chunks/pages/_app-b555d5e1eab47959.js  195 B
  └ chunks/webpack-737972036df45a17.js     1.64 kB

○  (Static)  automatically rendered as static HTML (uses no initial props)
yutakobayashidev commented 1 year ago

@janpio Starting with typescript 5.1.3, it is no longer necessary to give @ts-expect-error to the server component. However, updating to 5.1.3 is causing the same error as this issue

Vercel Build log:

- info Linting and checking validity of types...
> Build error occurred
RangeError: Maximum call stack size exceeded
    at inferFromTypes (/vercel/path0/frontend/node_modules/.pnpm/typescript@5.1.3/node_modules/typescript/lib/typescript.js:65452:30)
    at inferFromTypes (/vercel/path0/frontend/node_modules/.pnpm/typescript@5.1.3/node_modules/typescript/lib/typescript.js:65459:11)
    at inferFromTypes (/vercel/path0/frontend/node_modules/.pnpm/typescript@5.1.3/node_modules/typescript/lib/typescript.js:65459:11)
    at inferFromTypes (/vercel/path0/frontend/node_modules/.pnpm/typescript@5.1.3/node_modules/typescript/lib/typescript.js:65459:11)
    at inferFromTypes (/vercel/path0/frontend/node_modules/.pnpm/typescript@5.1.3/node_modules/typescript/lib/typescript.js:65459:11)
    at inferFromTypes (/vercel/path0/frontend/node_modules/.pnpm/typescript@5.1.3/node_modules/typescript/lib/typescript.js:65459:11)
    at inferFromTypes (/vercel/path0/frontend/node_modules/.pnpm/typescript@5.1.3/node_modules/typescript/lib/typescript.js:65459:11)
    at inferFromTypes (/vercel/path0/frontend/node_modules/.pnpm/typescript@5.1.3/node_modules/typescript/lib/typescript.js:65459:11)
    at inferFromTypes (/vercel/path0/frontend/node_modules/.pnpm/typescript@5.1.3/node_modules/typescript/lib/typescript.js:65459:11)
    at inferFromTypes (/vercel/path0/frontend/node_modules/.pnpm/typescript@5.1.3/node_modules/typescript/lib/typescript.js:65459:11) {
  type: 'RangeError'
}
 ELIFECYCLE  Command failed with exit code 1.
Error: Command "pnpm run build" exited with 1
BUILD_UTILS_SPAWN_1: Command "pnpm run build" exited with 1

Currently my project is downgrading a dependency to temporarily avoid the error.

janpio commented 1 year ago

We dug a bit deeper:

There are two related issues in the Typescript repo: https://github.com/microsoft/TypeScript/issues/54618 + https://github.com/microsoft/TypeScript/issues/54549 The second mentions that the 5.2.0-dev version might already fix this, and indeed: 5.2.0-dev.20230605 is still broken, but 5.2.0-dev.20230606 works again.

thanosoncode commented 1 year ago

5.2.0-dev.20230606 conflicts with eslint-config-next@13.4.4 when building in Vercel

npm ERR! code ERESOLVE
--
10:40:52.955 | npm ERR! ERESOLVE could not resolve
10:40:52.956 | npm ERR!
10:40:52.956 | npm ERR! While resolving: eslint-config-next@13.4.4
10:40:52.956 | npm ERR! Found: typescript@5.2.0-dev.20230606
10:40:52.956 | npm ERR! node_modules/typescript
10:40:52.957 | npm ERR!   typescript@"5.2.0-dev.20230606" from the root project
10:40:52.957 | npm ERR!
10:40:52.957 | npm ERR! Could not resolve dependency:
10:40:52.957 | npm ERR! peerOptional typescript@">=3.3.1" from eslint-config-next@13.4.4
10:40:52.957 | npm ERR! node_modules/eslint-config-next
10:40:52.960 | npm ERR!   eslint-config-next@"13.4.4" from the root project
10:40:52.960 | npm ERR!
10:40:52.960 | npm ERR! Conflicting peer dependency: typescript@5.1.3
10:40:52.960 | npm ERR! node_modules/typescript
10:40:52.960 | npm ERR!   peerOptional typescript@">=3.3.1" from eslint-config-next@13.4.4
10:40:52.961 | npm ERR!   node_modules/eslint-config-next
10:40:52.961 | npm ERR!     eslint-config-next@"13.4.4" from the root project
phihungtf commented 1 year ago

Same with me.

npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: eslint-config-next@13.4.2
npm ERR! Found: typescript@5.2.0-dev.20230619
npm ERR! node_modules/typescript
npm ERR!   dev typescript@"^5.2.0-dev.20230619" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peerOptional typescript@">=3.3.1" from eslint-config-next@13.4.2
npm ERR! node_modules/eslint-config-next
npm ERR!   eslint-config-next@"^13.4.2" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: typescript@5.1.3
npm ERR! node_modules/typescript
npm ERR!   peerOptional typescript@">=3.3.1" from eslint-config-next@13.4.2
npm ERR!   node_modules/eslint-config-next
npm ERR!     eslint-config-next@"^13.4.2" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
Jolg42 commented 1 year ago

@thanosoncode @phihungtf Optimally the TypeScript team releases a new patch version and you would switch to that instead of using the "dev" version.

Meanwhile, I think adding this in your package.json would unblock your projects

"overrides": {
  "typescript": "5.2.0-dev.20230606"
},

Or alternatively adding --force or --legacy-peer-deps to npm i like mentioned in the error message (Vercel docs to customize the command here).

jpmadrigal07 commented 1 year ago

A temporary workaround might be to downgrade to the previous typescript version: npm install typescript@5.0.4

PS C:\Users\Jan\Documents\throwaway\19715\my-app> npx next build
- info Loaded env from C:\Users\Jan\Documents\throwaway\19715\my-app\.env
- info Creating an optimized production build
- info Compiled successfully
- info Linting and checking validity of types
- info Collecting page data
- info Generating static pages (4/4)
- info Finalizing page optimization

Route (app)                                Size     First Load JS
┌ ○ /                                      4.78 kB          82 kB
└ ○ /favicon.ico                           0 B                0 B
+ First Load JS shared by all              77.3 kB
  ├ chunks/488-2398932694129a7b.js         24.9 kB
  ├ chunks/bce60fc1-49ee79ad31766ac6.js    50.5 kB
  ├ chunks/main-app-297b12279ce3dd6b.js    215 B
  └ chunks/webpack-737972036df45a17.js     1.64 kB

Route (pages)                              Size     First Load JS
─ ○ /404                                   181 B          74.7 kB
+ First Load JS shared by all              74.5 kB
  ├ chunks/framework-8883d1e9be70c3da.js   45.1 kB
  ├ chunks/main-66891548548be155.js        27.6 kB
  ├ chunks/pages/_app-b555d5e1eab47959.js  195 B
  └ chunks/webpack-737972036df45a17.js     1.64 kB

○  (Static)  automatically rendered as static HTML (uses no initial props)

This works for me

Jolg42 commented 1 year ago

TypeScript 5.1.5 is available: https://github.com/microsoft/TypeScript/releases/tag/v5.1.5 Did anyone try it? Does it solve the issue?

Joostdeboer commented 1 year ago

I had this issue as well while testing with Typescript 5.1.3. I just upgraded to Typescript v5.1.6 and my code seems to run without issues again. I suggest you give it a try and see if it helps fixing your problem too.

I upgraded to v5.1.6 (the latest as per the npm package) not 5.1.5. Version 5.1.5 does not work, 5.1.6 does work.

briankostar commented 1 year ago

I see same issue in typescript 5.1.6

Jolg42 commented 1 year ago

@briankostar Could you provide a minimal reproduction?

jameslporter commented 1 year ago

I'm seeing the same issue, none of the mentioned workarounds alleviated the fault. For my code it was a very simple server action fetching data from mongodb via mongoose. If I remove the .populate function the page renders fine. I know it worked at some point because I saw the field in the console output. I'm using nodejs 20.5.0 via asdf. I'm also regularly getting out of memory errors despite having plenty available on the system. I noticed there's orphaned processes when that happens named next-render-worker-pages.

jameslporter commented 1 year ago

Just found the root cause for my code. The problem was that I was returning mongoose result objects, gotta call .lean() and the error goes away. Console still complains about it not being a plain object as the _id field is a mongo ObjectId type. In a similar working action I mapped over the lean results and set _id to name._id.toString() to eliminate the console warning about object type not being a POJO.

janpio commented 1 year ago

Thanks for your comments @jameslporter, but as you do not use Prisma but Mongoose this is not relevant to our problem. I hid them.

vickkhera commented 1 year ago

I'm observing the same error with "typescript": "^5.2.2" building my next.js app:

> Build error occurred
RangeError: Maximum call stack size exceeded
    at getTypeAtFlowBranchLabel (/Users/vick/Work/Carfeine/intelligent-inventory/node_modules/typescript/lib/typescript.js:67879:40)
    at getTypeAtFlowNode (/Users/vick/Work/Carfeine/intelligent-inventory/node_modules/typescript/lib/typescript.js:67683:50)
    at getTypeAtFlowBranchLabel (/Users/vick/Work/Carfeine/intelligent-inventory/node_modules/typescript/lib/typescript.js:67889:28)
    at getTypeAtFlowNode (/Users/vick/Work/Carfeine/intelligent-inventory/node_modules/typescript/lib/typescript.js:67683:50)
    at getTypeAtFlowBranchLabel (/Users/vick/Work/Carfeine/intelligent-inventory/node_modules/typescript/lib/typescript.js:67889:28)
    at getTypeAtFlowNode (/Users/vick/Work/Carfeine/intelligent-inventory/node_modules/typescript/lib/typescript.js:67683:50)
    at getTypeAtFlowBranchLabel (/Users/vick/Work/Carfeine/intelligent-inventory/node_modules/typescript/lib/typescript.js:67889:28)
    at getTypeAtFlowNode (/Users/vick/Work/Carfeine/intelligent-inventory/node_modules/typescript/lib/typescript.js:67683:50)
    at getTypeAtFlowCondition (/Users/vick/Work/Carfeine/intelligent-inventory/node_modules/typescript/lib/typescript.js:67831:26)
    at getTypeAtFlowNode (/Users/vick/Work/Carfeine/intelligent-inventory/node_modules/typescript/lib/typescript.js:67675:20) {
  type: 'RangeError'
}

To get it to build on Vercel, I had to make my build script set the stack-size to 5000.

zaplpro commented 1 year ago

Installing tailwind@5.2.2 solved the issue for me.

MusabDev commented 1 year ago

Installing tailwind@5.2.2 solved the issue for me.

Tailwind or Typescript?

yh919 commented 12 months ago

i face this errors while building

RangeError: Maximum call stack size exceeded
--
05:26:29.985 | at P (/vercel/path0/.next/server/chunks/686.js:10:66480)
05:26:29.985 | at l (/vercel/path0/.next/server/chunks/686.js:10:61660)
05:26:29.986 | at /vercel/path0/.next/server/chunks/686.js:10:62861
05:26:29.986 | at Array.forEach (<anonymous>)
05:26:29.986 | at /vercel/path0/.next/server/chunks/686.js:10:62834
05:26:29.987 | at Array.forEach (<anonymous>)
05:26:29.987 | at a (/vercel/path0/.next/server/chunks/686.js:10:62654)
05:26:29.987 | at /vercel/path0/.next/server/chunks/686.js:10:62918
05:26:29.987 | at Array.forEach (<anonymous>)
05:26:29.988 | at l (/vercel/path0/.next/server/chunks/686.js:10:62611)
05:26:29.988 |  
05:26:29.988 | Error occurred prerendering page "/applications". Read more: https://nextjs.org/docs/messages/prerender-error
05:26:29.988 | RangeError: Maximum call stack size exceeded
05:26:29.989 | at P (/vercel/path0/.next/server/chunks/686.js:10:66480)
05:26:29.989 | at l (/vercel/path0/.next/server/chunks/686.js:10:61660)
05:26:29.989 | at /vercel/path0/.next/server/chunks/686.js:10:62861
05:26:29.989 | at Array.forEach (<anonymous>)
05:26:29.990 | at /vercel/path0/.next/server/chunks/686.js:10:62834
05:26:29.990 | at Array.forEach (<anonymous>)
05:26:29.990 | at a (/vercel/path0/.next/server/chunks/686.js:10:62654)
05:26:29.990 | at /vercel/path0/.next/server/chunks/686.js:10:62918
05:26:29.990 | at Array.forEach (<anonymous>)
05:26:29.991 | at l (/vercel/path0/.next/server/chunks/686.js:10:62611)
05:26:31.090 | RangeError: Maximum call stack size exceeded
05:26:31.090 | at P (/vercel/path0/.next/server/chunks/686.js:10:66480)
05:26:31.090 | at l (/vercel/path0/.next/server/chunks/686.js:10:61660)
05:26:31.090 | at /vercel/path0/.next/server/chunks/686.js:10:62861
05:26:31.091 | at Array.forEach (<anonymous>)
05:26:31.091 | at /vercel/path0/.next/server/chunks/686.js:10:62834
05:26:31.091 | at Array.forEach (<anonymous>)
05:26:31.091 | at a (/vercel/path0/.next/server/chunks/686.js:10:62654)
05:26:31.091 | at /vercel/path0/.next/server/chunks/686.js:10:62918
05:26:31.091 | at Array.forEach (<anonymous>)
05:26:31.091 | at l (/vercel/path0/.next/server/chunks/686.js:10:62611)
05:26:31.091 |  
05:26:31.091 | Error occurred prerendering page "/team". Read more: https://nextjs.org/docs/messages/prerender-error
05:26:31.091 | RangeError: Maximum call stack size exceeded
05:26:31.091 | at P (/vercel/path0/.next/server/chunks/686.js:10:66480)
05:26:31.091 | at l (/vercel/path0/.next/server/chunks/686.js:10:61660)
05:26:31.091 | at /vercel/path0/.next/server/chunks/686.js:10:62861
05:26:31.091 | at Array.forEach (<anonymous>)
05:26:31.091 | at /vercel/path0/.next/server/chunks/686.js:10:62834
05:26:31.091 | at Array.forEach (<anonymous>)
05:26:31.091 | at a (/vercel/path0/.next/server/chunks/686.js:10:62654)
05:26:31.091 | at /vercel/path0/.next/server/chunks/686.js:10:62918
05:26:31.091 | at Array.forEach (<anonymous>)
05:26:31.093 | at l (/vercel/path0/.next/server/chunks/686.js:10:62611)
05:26:31.112 | Generating static pages (6/9)
05:26:31.113 | RangeError: Maximum call stack size exceeded
05:26:31.113 | at P (/vercel/path0/.next/server/chunks/686.js:10:66098)
05:26:31.113 | at l (/vercel/path0/.next/server/chunks/686.js:10:61660)
05:26:31.113 | at /vercel/path0/.next/server/chunks/686.js:10:62861
05:26:31.113 | at Array.forEach (<anonymous>)
05:26:31.113 | at /vercel/path0/.next/server/chunks/686.js:10:62834
05:26:31.113 | at Array.forEach (<anonymous>)
05:26:31.114 | at a (/vercel/path0/.next/server/chunks/686.js:10:62654)
05:26:31.114 | at /vercel/path0/.next/server/chunks/686.js:10:62918
05:26:31.114 | at Array.forEach (<anonymous>)
05:26:31.114 | at l (/vercel/path0/.next/server/chunks/686.js:10:62611)
05:26:31.114 |  
05:26:31.114 | Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
05:26:31.114 | RangeError: Maximum call stack size exceeded
05:26:31.115 | at P (/vercel/path0/.next/server/chunks/686.js:10:66098)
05:26:31.115 | at l (/vercel/path0/.next/server/chunks/686.js:10:61660)
05:26:31.115 | at /vercel/path0/.next/server/chunks/686.js:10:62861
05:26:31.115 | at Array.forEach (<anonymous>)
05:26:31.115 | at /vercel/path0/.next/server/chunks/686.js:10:62834
05:26:31.115 | at Array.forEach (<anonymous>)
05:26:31.115 | at a (/vercel/path0/.next/server/chunks/686.js:10:62654)
05:26:31.116 | at /vercel/path0/.next/server/chunks/686.js:10:62918
05:26:31.116 | at Array.forEach (<anonymous>)
05:26:31.116 | at l (/vercel/path0/.next/server/chunks/686.js:10:62611)
05:26:31.116 | RangeError: Maximum call stack size exceeded
05:26:31.116 | at P (/vercel/path0/.next/server/chunks/686.js:10:66480)
05:26:31.116 | at l (/vercel/path0/.next/server/chunks/686.js:10:61660)
05:26:31.116 | at /vercel/path0/.next/server/chunks/686.js:10:62861
05:26:31.117 | at Array.forEach (<anonymous>)
05:26:31.117 | at /vercel/path0/.next/server/chunks/686.js:10:62834
05:26:31.117 | at Array.forEach (<anonymous>)
05:26:31.117 | at a (/vercel/path0/.next/server/chunks/686.js:10:62654)
05:26:31.117 | at /vercel/path0/.next/server/chunks/686.js:10:62918
05:26:31.117 | at Array.forEach (<anonymous>)
05:26:31.117 | at l (/vercel/path0/.next/server/chunks/686.js:10:62611)
05:26:31.118 |  
05:26:31.118 | Error occurred prerendering page "/application". Read more: https://nextjs.org/docs/messages/prerender-error
05:26:31.118 | RangeError: Maximum call stack size exceeded
05:26:31.118 | at P (/vercel/path0/.next/server/chunks/686.js:10:66480)
05:26:31.118 | at l (/vercel/path0/.next/server/chunks/686.js:10:61660)
05:26:31.118 | at /vercel/path0/.next/server/chunks/686.js:10:62861
05:26:31.118 | at Array.forEach (<anonymous>)
05:26:31.119 | at /vercel/path0/.next/server/chunks/686.js:10:62834
05:26:31.119 | at Array.forEach (<anonymous>)
05:26:31.119 | at a (/vercel/path0/.next/server/chunks/686.js:10:62654)
05:26:31.119 | at /vercel/path0/.next/server/chunks/686.js:10:62918
05:26:31.119 | at Array.forEach (<anonymous>)
05:26:31.119 | at l (/vercel/path0/.next/server/chunks/686.js:10:62611)
05:26:33.072 | RangeError: Maximum call stack size exceeded
05:26:33.072 | at P (/vercel/path0/.next/server/chunks/686.js:10:66480)
05:26:33.072 | at l (/vercel/path0/.next/server/chunks/686.js:10:61660)
05:26:33.072 | at /vercel/path0/.next/server/chunks/686.js:10:62861
05:26:33.073 | at Array.forEach (<anonymous>)
05:26:33.073 | at /vercel/path0/.next/server/chunks/686.js:10:62834
05:26:33.073 | at Array.forEach (<anonymous>)
05:26:33.073 | at a (/vercel/path0/.next/server/chunks/686.js:10:62654)
05:26:33.073 | at /vercel/path0/.next/server/chunks/686.js:10:62918
05:26:33.073 | at Array.forEach (<anonymous>)
05:26:33.074 | at l (/vercel/path0/.next/server/chunks/686.js:10:62611)
05:26:33.074 |  
05:26:33.074 | Error occurred prerendering page "/edituser". Read more: https://nextjs.org/docs/messages/prerender-error
05:26:33.074 | RangeError: Maximum call stack size exceeded
05:26:33.075 | at P (/vercel/path0/.next/server/chunks/686.js:10:66480)
05:26:33.075 | at l (/vercel/path0/.next/server/chunks/686.js:10:61660)
05:26:33.075 | at /vercel/path0/.next/server/chunks/686.js:10:62861
05:26:33.075 | at Array.forEach (<anonymous>)
05:26:33.076 | at /vercel/path0/.next/server/chunks/686.js:10:62834
05:26:33.076 | at Array.forEach (<anonymous>)
05:26:33.076 | at a (/vercel/path0/.next/server/chunks/686.js:10:62654)
05:26:33.076 | at /vercel/path0/.next/server/chunks/686.js:10:62918
05:26:33.076 | at Array.forEach (<anonymous>)
05:26:33.076 | at l (/vercel/path0/.next/server/chunks/686.js:10:62611)
Jolg42 commented 11 months ago

@yh919 Please open a new issue and provide the required information to be able to reproduce this.

nghilethanh-atherlabs commented 11 months ago

This next13 drives me a lot of bugs

EverettQuebral commented 10 months ago

got the same thing, using typescript 5.1.6

only happening when I run the build

RangeError: Maximum call stack size exceeded
    at P (3068-b5a399783fbcb1fd.js:5:30167)
    at l (3068-b5a399783fbcb1fd.js:5:25358)
    at 3068-b5a399783fbcb1fd.js:5:26559
    at Array.forEach (<anonymous>)
    at 3068-b5a399783fbcb1fd.js:5:26532
    at Array.forEach (<anonymous>)
    at a (3068-b5a399783fbcb1fd.js:5:26352)
    at 3068-b5a399783fbcb1fd.js:5:26616
    at Array.forEach (<anonymous>)
    at l (3068-b5a399783fbcb1fd.js:5:26309)
zihadm654 commented 9 months ago
RangeError: Maximum call stack size exceeded
19:07:47.104 | at RegExp.exec (<anonymous>)
19:07:47.105 | at create (/vercel/path0/node_modules/.pnpm/next@14.0.3_@babel+core@7.23.5_react-dom@18.2.0_react@18.2.0_sass@1.69.5/node_modules/next/dist/compiled/micromatch/index.js:15:18889)
19:07:47.105 | at create (/vercel/path0/node_modules/.pnpm/next@14.0.3_@babel+core@7.23.5_react-dom@18.2.0_react@18.2.0_sass@1.69.5/node_modules/next/dist/compiled/micromatch/index.js:15:18918)
19:07:47.105 | at parse.fastpaths (/vercel/path0/node_modules/.pnpm/next@14.0.3_@babel+core@7.23.5_react-dom@18.2.0_react@18.2.0_sass@1.69.5/node_modules/next/dist/compiled/micromatch/index.js:15:18997)
19:07:47.105 | at picomatch.makeRe (/vercel/path0/node_modules/.pnpm/next@14.0.3_@babel+core@7.23.5_react-dom@18.2.0_react@18.2.0_sass@1.69.5/node_modules/next/dist/compiled/micromatch/index.js:15:21635)
19:07:47.105 | at picomatch (/vercel/path0/node_modules/.pnpm/next@14.0.3_@babel+core@7.23.5_react-dom@18.2.0_react@18.2.0_sass@1.69.5/node_modules/next/dist/compiled/micromatch/index.js:15:19637)
19:07:47.105 | at /vercel/path0/node_modules/.pnpm/next@14.0.3_@babel+core@7.23.5_react-dom@18.2.0_react@18.2.0_sass@1.69.5/node_modules/next/dist/compiled/micromatch/index.js:15:19294
19:07:47.105 | at Array.map (<anonymous>)
19:07:47.106 | at picomatch (/vercel/path0/node_modules/.pnpm/next@14.0.3_@babel+core@7.23.5_react-dom@18.2.0_react@18.2.0_sass@1.69.5/node_modules/next/dist/compiled/micromatch/index.js:15:19286)
19:07:47.106 | at micromatch.isMatch (/vercel/path0/node_modules/.pnpm/next@14.0.3_@babel+core@7.23.5_react-dom@18.2.0_react@18.2.0_sass@1.69.5/node_modules/next/dist/compiled/micromatch/index.js:15:1090)
19:07:47.176 | ELIFECYCLE  Command failed with exit code 1.
19:07:47.198 | Error: Command "pnpm run build" exited with 1
Jolg42 commented 9 months ago

@EverettQuebral @zihadm654 Please open a new issue and provide the required information to be able to reproduce this.

@zihadm654 For example, we would need to know which version of TypeScript you are using.

If you can provide a reproduction repository, it would help a lot 🙌🏼

Note that this is a general TypeScript error, and it could be caused by Prisma or not and will depend on your specific codebase, please verify that this is actually triggered by Prisma Client and which version.

nghilethanh-atherlabs commented 9 months ago

Still work with version "next": "13.5.7-canary.25"

artemshchirov commented 8 months ago

@zihadm654 Hi! Did you find a solution for this error?

vigneshwaran-48 commented 8 months ago

For me removing the package "sharp" from package.json resolved the issue.

zihadm654 commented 8 months ago

@zihadm654 Hi! Did you find a solution for this error?

it was not related to prisma it was related to a function calling again and again that's why the error occur.

AnkurParchani commented 8 months ago

For me removing the package "sharp" from package.json resolved the issue.

Same with me, I removed sharp package and it started working fine.

Creativeart455 commented 8 months ago

in my case i was using persian-tools/persian-tools to convert number to word. commenting the section that i would use this library's methods to convert numbers to words, solved my problem.

ProgrammerRashed commented 7 months ago

Removing the Sharp package solved the problem for me. It seems that the Sharp package was causing conflicts or issues, and removing it resolved the issue.

janpio commented 7 months ago

Anyone commenting on this: Please make sure to mention if you also use prisma and/or @prisma/client in your project. If not, you are not really in the correct repository and we might just be able to close this issue as nothing is wrong with Prisma any more. Thank you!

frankdagostino commented 7 months ago

Removing the Sharp package solved the problem for me. It seems that the Sharp package was causing conflicts or issues, and removing it resolved the issue.

confirmed!

flan02 commented 5 months ago

I had the same problem since I tried to send via props drilling from a server component to a client component an object with the error "Maximux call stack exceed" and to me the solution was:

const ServerComponent = async ({ params }: Props) => {
  const session = await getAuthSession()
  if (!session?.user) return redirect('/')

  const game = await getGame(params.gameId)
  const gameParsed = JSON.parse(JSON.stringify(game))
  return (
<ClientComponent game={gameParsed} />
)
}
export default const ClientComponent = ( { game } : Props ) =>
const { ...rest } = game
 return (
// use the props here because your maximux exceed problem won't be exist anymore
)

CHEERS ! 🎄