Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when building nextjs 15 app while prerendering /500 & /404 (only happens with turborepo) #9335

Open
1 task done
ezeamin opened this issue Oct 25, 2024 · 2 comments
Open
1 task done
Labels
kind: bug Something isn't working needs: author input

Comments

@ezeamin
Copy link

ezeamin commented Oct 25, 2024

Verify canary release

  • I verified that the issue exists in the latest Turborepo canary release.

Link to code that reproduces this issue

https://github.com/ezeamin/turbo-next-15

What package manager are you using / does the bug impact?

npm

What operating system are you using?

Windows

Which canary version will you have in your reproduction?

[email protected]

Describe the Bug

When minimal nextjs app (15.0.1 & 15.0.2-canary.6 - latest up to today) is being built, these errors appear:

┌ home#build > cache miss, executing 570f9f11bf8e8c82
│
│ > [email protected] build
│ > next build
│
│   ▲ Next.js 15.0.1
│
│    Creating an optimized production build ...
│  ✓ Compiled successfully
│  ✓ Linting and checking validity of types
│  ✓ Collecting page data
│ Error: Minified React error #31; visit https://reactjs.org/docs/error-decoder.html?invariant=31&args[]=object%20with%20keys%20%7B%24%24typeof%2C%20type%2C%20key%2C%20ref%2C%
│ 20props%7D for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
│     at Z (C:\Users\Amin\Documents\Codigo\Pruebas\turbo-next-15\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:76:490)
│     at Xc (C:\Users\Amin\Documents\Codigo\Pruebas\turbo-next-15\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:68:409)
│     at Zc (C:\Users\Amin\Documents\Codigo\Pruebas\turbo-next-15\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:70:210)
│     at Z (C:\Users\Amin\Documents\Codigo\Pruebas\turbo-next-15\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:76:89)
│     at Zc (C:\Users\Amin\Documents\Codigo\Pruebas\turbo-next-15\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:70:481)
│     at Z (C:\Users\Amin\Documents\Codigo\Pruebas\turbo-next-15\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:76:89)
│     at $c (C:\Users\Amin\Documents\Codigo\Pruebas\turbo-next-15\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:78:98)
│     at bd (C:\Users\Amin\Documents\Codigo\Pruebas\turbo-next-15\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:77:404)
│     at Z (C:\Users\Amin\Documents\Codigo\Pruebas\turbo-next-15\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:76:217)
│     at Zc (C:\Users\Amin\Documents\Codigo\Pruebas\turbo-next-15\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:71:479)
│ Error occurred prerendering page "/404". Read more: https://nextjs.org/docs/messages/prerender-error
│ Error: Minified React error #31; visit https://reactjs.org/docs/error-decoder.html?invariant=31&args[]=object%20with%20keys%20%7B%24%24typeof%2C%20type%2C%20key%2C%20ref%2C%
│ 20props%7D for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
│     at Z (C:\Users\Amin\Documents\Codigo\Pruebas\turbo-next-15\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:76:490)
│     at Xc (C:\Users\Amin\Documents\Codigo\Pruebas\turbo-next-15\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:68:409)
│     at Zc (C:\Users\Amin\Documents\Codigo\Pruebas\turbo-next-15\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:70:210)
│     at Z (C:\Users\Amin\Documents\Codigo\Pruebas\turbo-next-15\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:76:89)
│     at Zc (C:\Users\Amin\Documents\Codigo\Pruebas\turbo-next-15\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:70:481)
│     at Z (C:\Users\Amin\Documents\Codigo\Pruebas\turbo-next-15\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:76:89)
│     at $c (C:\Users\Amin\Documents\Codigo\Pruebas\turbo-next-15\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:78:98)
│     at bd (C:\Users\Amin\Documents\Codigo\Pruebas\turbo-next-15\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:77:404)
│     at Z (C:\Users\Amin\Documents\Codigo\Pruebas\turbo-next-15\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:76:217)
│     at Zc (C:\Users\Amin\Documents\Codigo\Pruebas\turbo-next-15\node_modules\react-dom\cjs\react-dom-server.browser.production.min.js:71:479)
│ Export encountered an error on /_error: /404, exiting the build.
│  ⨯ Static worker exited with code: 1 and signal: null
│ npm error Lifecycle script `build` failed with error:
│ npm error code 1
│ npm error path C:\Users\Amin\Documents\Codigo\Pruebas\turbo-next-15\apps\home
│ npm error workspace [email protected]
│ npm error location C:\Users\Amin\Documents\Codigo\Pruebas\turbo-next-15\apps\home
│ npm error command failed
│ npm error command C:\WINDOWS\system32\cmd.exe /d /s /c next build
│ command finished with error: command (C:\Users\Amin\Documents\Codigo\Pruebas\turbo-next-15\apps\home) C:\Program Files\nodejs\npm.cmd run build exited (1)
└────>
home#build: command (C:\Users\Amin\Documents\Codigo\Pruebas\turbo-next-15\apps\home) C:\Program Files\nodejs\npm.cmd run build exited (1)

This may seem a nextjs error, but it doesn't happen outside of a monorepo handled by turborepo.

It sometimes shows error while prerendering /404, and sometimes while prerendering /500. This WASN'T happening with nextjs@14. This is shown when "Generating static pages (0/4)" is run, after other stages had finished successfully..

Dev execution runs without problems. Running npm run build from apps/home also shows the same errors.

It also occurs with [email protected], tested on linux and windows.

Expected Behavior

Build finishes without any problems.

To Reproduce

  1. Run npm i --force (to avoid react@19 peer deps errors)
  2. Run npm run build
  3. See console output.

Additional context

I tested this on different PCs, using next 15,15.0.1, and over canary release 15.0.2-canary.6. Also tested on docker.

@ezeamin ezeamin added kind: bug Something isn't working needs: triage New issues get this label. Remove it after triage labels Oct 25, 2024
@chris-olszewski
Copy link
Member

I'm confused by the following statements:

This may seem a nextjs error, but it doesn't happen outside of a monorepo handled by turborepo.

Running npm run build from apps/home also shows the same errors.

So does the error only appear once npm add -D turbo is run in the repository? I removed any turbo installation and configuration in the repro you provided and the error remained when I ran npm run build from apps/home. Could you provide a repro without Turborepo that works as expected?

@chris-olszewski chris-olszewski added needs: author input and removed needs: triage New issues get this label. Remove it after triage labels Oct 28, 2024
@ezeamin
Copy link
Author

ezeamin commented Oct 28, 2024

Hi @chris-olszewski. Sure do. Try this: https://github.com/ezeamin/non-turbo-next-15 (which is the same empty nextjs 15 app, I just took it off the monorepo). You'll see it builds successfully:
{ADA8CF9B-2D08-4961-9CB6-FAEEBDE388EC}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug Something isn't working needs: author input
Projects
None yet
Development

No branches or pull requests

2 participants