vercel / next.js

The React Framework
https://nextjs.org
MIT License
125.12k stars 26.73k forks source link

Build error while using global-error file inside app/[lang] folder #59053

Closed mertafor closed 9 months ago

mertafor commented 9 months ago

Link to the code that reproduces this issue

https://github.com/mertafor/next-error-template-issue

To Reproduce

Try to build the minimal repo and get a build error

> next-error-template-issue@0.1.0 build /Users/mertdaglaroglu/Documents/WebProjects/Reactive/comnet/next-error-template-issue
> next build

 ⚠ Invalid next.config.mjs options detected: 
 ⚠     Expected object, received boolean at "experimental.serverActions"
 ⚠ See more info here: https://nextjs.org/docs/messages/invalid-next-config
 ⚠ Server Actions are available by default now, `experimental.serverActions` option can be safely removed.
   ▲ Next.js 14.0.4-canary.25

 ✓ Creating an optimized production build    
 ✓ Compiled successfully
 ✓ Linting and checking validity of types    
 ✓ Collecting page data    
   Generating static pages (0/5)  [    ]Error: Could not find the module "/Users/mertdaglaroglu/Documents/WebProjects/Reactive/comnet/next-error-template-issue/node_modules/.pnpm/next@14.0.4-canary.25_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/client/components/error-boundary.js#" in the React Client Manifest. This is probably a bug in the React Server Components bundler.
    at eS (/Users/mertdaglaroglu/Documents/WebProjects/Reactive/comnet/next-error-template-issue/node_modules/.pnpm/next@14.0.4-canary.25_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:129803)
    at /Users/mertdaglaroglu/Documents/WebProjects/Reactive/comnet/next-error-template-issue/node_modules/.pnpm/next@14.0.4-canary.25_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:142519
    at Object.toJSON (/Users/mertdaglaroglu/Documents/WebProjects/Reactive/comnet/next-error-template-issue/node_modules/.pnpm/next@14.0.4-canary.25_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:143612)
    at stringify (<anonymous>)
    at eE (/Users/mertdaglaroglu/Documents/WebProjects/Reactive/comnet/next-error-template-issue/node_modules/.pnpm/next@14.0.4-canary.25_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:131997)
    at eR (/Users/mertdaglaroglu/Documents/WebProjects/Reactive/comnet/next-error-template-issue/node_modules/.pnpm/next@14.0.4-canary.25_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:132440)
    at Timeout._onTimeout (/Users/mertdaglaroglu/Documents/WebProjects/Reactive/comnet/next-error-template-issue/node_modules/.pnpm/next@14.0.4-canary.25_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:129220)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7)
Error: Could not find the module "/Users/mertdaglaroglu/Documents/WebProjects/Reactive/comnet/next-error-template-issue/node_modules/.pnpm/next@14.0.4-canary.25_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/client/components/error-boundary.js#" in the React Client Manifest. This is probably a bug in the React Server Components bundler.
    at eS (/Users/mertdaglaroglu/Documents/WebProjects/Reactive/comnet/next-error-template-issue/node_modules/.pnpm/next@14.0.4-canary.25_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:129803)
    at /Users/mertdaglaroglu/Documents/WebProjects/Reactive/comnet/next-error-template-issue/node_modules/.pnpm/next@14.0.4-canary.25_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:142519
    at Object.toJSON (/Users/mertdaglaroglu/Documents/WebProjects/Reactive/comnet/next-error-template-issue/node_modules/.pnpm/next@14.0.4-canary.25_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:143612)
    at stringify (<anonymous>)
    at eE (/Users/mertdaglaroglu/Documents/WebProjects/Reactive/comnet/next-error-template-issue/node_modules/.pnpm/next@14.0.4-canary.25_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:131997)
    at eR (/Users/mertdaglaroglu/Documents/WebProjects/Reactive/comnet/next-error-template-issue/node_modules/.pnpm/next@14.0.4-canary.25_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:132440)
    at Timeout._onTimeout (/Users/mertdaglaroglu/Documents/WebProjects/Reactive/comnet/next-error-template-issue/node_modules/.pnpm/next@14.0.4-canary.25_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:129220)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7)
[Error: An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error.] {
  digest: '910671031'
}

Error occurred prerendering page "/_not-found". Read more: https://nextjs.org/docs/messages/prerender-error
Error: An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error.
 ✓ Generating static pages (5/5) 

> Export encountered errors on following paths:
        /_not-found
 ELIFECYCLE  Command failed with exit code 1.

Current vs. Expected behavior

Nextjs docs recommends placing global-error file inside app folder. However there is no instructions for internalization. Placing this file inside app/[lang] folder works just fine in dev environment yet it throws build error during static route generation. This looks like a build error rather than global-error file.

I've already created an issue about this along with not-found errors 2 months back and many reported same problem. However there is no solution to this problem yet (updated to the latest canary): https://github.com/vercel/next.js/issues/56259

Due to missing global error file, website displays this on production build (browser's default JS error I guess): Screenshot 2023-11-29 at 11 11 33

Verify canary release

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.1.0: Mon Oct  9 21:28:45 PDT 2023; root:xnu-10002.41.9~6/RELEASE_ARM64_T6020
Binaries:
  Node: 20.5.1
  npm: 9.8.0
  Yarn: 1.22.19
  pnpm: 8.11.0
Relevant Packages:
  next: 14.0.4-canary.25
  eslint-config-next: 14.0.3
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.3.2
Next.js Config:
  output: N/A

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

App Router

Additional context

I tested this with latest canary 14.0.4-canary.25 and problem still exist.

It works before v13.4.20-canary.12

github-actions[bot] commented 9 months ago

This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.