Repository navigation
Closed
Closed
Copy link
Description
Link to the code that reproduces this issue
To Reproduce
- Create a new Next.js app:
pnpm create next-app@latest
- Create route groups:
mkdir -p app/'(group1)' app/'(group2)'/path && \
cp app/page.tsx app/'(group1)'/page.tsx && \
cp app/layout.tsx app/'(group1)'/layout.tsx && \
cp app/layout.tsx app/'(group2)'/layout.tsx && \
cp app/page.tsx app/'(group2)'/path/page.tsx
- Remove root layout and page:
rm app/page.tsx app/layout.tsx
- Enable experimental flag in next.config.ts:
export default {
experimental: {
globalNotFound: true,
},
}
- Create app/global-not-found.tsx with an import:
import './globals.css';
export default function GlobalNotFound() {
return (
<html lang="en">
<body>
<h1>404 - Page Not Found</h1>
<p>This page does not exist.</p>
</body>
</html>
);
}
- Run:
pnpm run dev
Current vs. Expected behavior
Expected:
- global-not-found renders correctly
- dev server remains stable
Actual:
- Page fails to render correctly (blank or inconsistent)
- Dev server enters an infinite loop
- Multiple Node processes spawn
- High CPU usage
Key finding:
The issue is triggered by any import inside global-not-found.tsx.
Working version (no imports, same HTML structure):
export default function GlobalNotFound() {
return (
<html lang="en">
<body>
<h1>404 - Page Not Found</h1>
<p>This page does not exist.</p>
</body>
</html>
);
}
```tsx
### Provide environment information
```bash
Operating System:
Platform: linux
Arch: x64
Version: #20~24.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Mar 19 01:28:37 UTC 2
Available memory (MB): 11851
Available CPU cores: 4
Binaries:
Node: 25.1.0
npm: 11.6.2
Yarn: N/A
pnpm: 10.32.1
Relevant Packages:
next: 16.2.2 // Latest available version is detected (16.2.2).
eslint-config-next: N/A
react: 19.2.4
react-dom: 19.2.4
typescript: 5.9.3
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
Not Found
Which stage(s) are affected? (Select all that apply)
next dev (local)
Additional context
-
The issue occurs even with minimal imports such as:
import './globals.css'; -
The problem is not related to JSX structure. The same component works correctly when no imports are present.
-
Regression:
- Works in [email protected]
- Broken in [email protected] and 16.2.2
-
Likely related to how global-not-found is handled as a special entry in the module graph when no root layout is present.
-
Reproducible locally.
Reacted by Flynn and sam9191
Reacted by devhowyalike
Activity
christopherjohnson3028-stack commentedon Apr 2, 2026
f1yn commentedon Apr 4, 2026
btophas captured this bug well for me (M4 Pro, 64GB). It's absolutely thrashing the CPU, and Next.js is spreading it across all cores.mischnic commentedon Apr 8, 2026
@intoRandom I can't reproduce it with your instructions.
I visited http://localhost:3000/ and http://localhost:3000/path but still don't see any infinite loop.
chcaru commentedon Jun 30, 2026
Another reproduction: this also hits the stable
not-found.tsx(noexperimental.globalNotFound, root layout present) on 16.2.7Since @mischnic couldn't reproduce the original repo, here's an independent data point in a different and arguably more common configuration. We hit what looks like the same infinite dev-recompile loop, but with a plain
app/not-found.tsx, noexperimental.globalNotFound, and a normal rootapp/layout.tsxpresent. That suggests the problem is in how the not-found special entry is handled in the module graph generally, not justglobal-not-found.Environment
[email protected],react/[email protected]next dev)experimental.globalNotFound, rootapp/layout.tsxexistsSymptom
.next/.../src_app_not-found_tsx_*.jsrewrites itself roughly every ~5s, forever. It compiles, immediately invalidates, recompiles. The loop is below the trace layer (Next'stracefile barely grows while CPU stays at 50%).What triggers it (the useful part)
In this configuration the trigger scales with the size of the imported module graph, not literally "any import":
not-found.tsximportsnext/link"use client"components + their deps)Removing that one heavy import drops idle CPU from ~50% to 0% instantly and the chunk stops recompiling. This may explain the non-repro: a trivial import (or a single
globals.css) may not be heavy enough to trip it in a config with a root layout. A large client-component graph reliably does.Minimal repro recipe
[email protected],[email protected],[email protected].app/layout.tsx. Do not setexperimental.globalNotFound.app/not-found.tsxthat statically imports a large client-component subtree (e.g., a component that itself imports a heavy client dependency such as a terminal emulator, plus ~a dozen"use client"components) and renders it.next dev, hit any 404 route once, then leave the server idle. Watch CPU and.nextforsrc_app_not-found_tsx_*.jsrewriting on a loop.One more note
We also observed comparable idle CPU under
next dev --webpack, so this may not be strictly Turbopack-specific, though we only positively confirmed the not-found-chunk recompile loop under Turbopack.Happy to put together a self-contained minimal reproduction repo if that would help narrow it down.
mischnic commentedon Jun 30, 2026
@chcaru does this still happen with
next@preview?NuclEnergy commentedon Jul 1, 2026
Problem reproduction in version 16.2.9: Next.js is mining cryptocurrency on my computer.
pratham-ak2004 commentedon Jul 4, 2026
I am encountering the same issue as well. Below is the config
next.config.tspackage.json (partial){ "dependencies:" { "next": "^16.2.9", "react": "^19.2.7", "react-dom": "^19.2.7", }, "devDependencies": { "babel-plugin-react-compiler": "^1.0.0", } }tsconfig.json{ "compilerOptions": { /* Base Options: */ "esModuleInterop": true, "skipLibCheck": true, "target": "es2022", "allowJs": true, "resolveJsonModule": true, "moduleDetection": "force", "isolatedModules": true, "verbatimModuleSyntax": true, /* Strictness */ "strict": true, "noUncheckedIndexedAccess": true, "checkJs": true, /* Bundled projects */ "lib": ["dom", "dom.iterable", "ES2022"], "noEmit": true, "module": "ESNext", "moduleResolution": "Bundler", "jsx": "react-jsx", "plugins": [ { "name": "next" } ], "incremental": true, /* Path Aliases */ "paths": { "~/*": ["./src/*"], "@/*": ["./generated/*"] } }, "include": [ "next-env.d.ts", "**/*.ts", "**/*.tsx", "**/*.cjs", "**/*.js", ".next/types/**/*.ts", ".next/dev/types/**/*.ts" ], "exclude": ["node_modules", "generated"] }global-not-found.tsx, using"use client"directive or importing any component or dependency (importingglobal.csstoo) causes the CPU and RAM to spikefix(web): avoid Next.js global-not-found import bug (vercel/next.js#9…
devhowyalike commentedon Jul 25, 2026
Confirming this on
16.2.10and16.2.11, and reporting that it appears fixed in16.3.0-preview.9.Adding measurements in case they help narrow it down — the headline is that a single
curlto an unmatched URL pins ~8 coresindefinitely, and the 404 response itself is fast, so the spin is background work that never terminates.
Environment
App shape matches the repro: two route groups (
app/(storefront),app/(admin)), no root layout, and anapp/global-not-found.tsxwith imports.
Symptom
One
curlto an unmatched path, then samplingnext-serverCPU:After ~2 minutes wall clock the process had accumulated 10:56 of CPU time (~9 cores saturated continuously). It shows no sign of
decaying — no additional requests, no browser attached, no HMR. Nothing further is printed to the dev server log.
What it is not
I isolated these one at a time, each with a fresh dev server:
notFound()from a matched route in a group (/tags/bogus)experimental.globalNotFound: false/nope.png)next dev --disable-source-mapsnext dev --webpacknext build && next start)Two things worth calling out:
globalNotFoundflag. Withexperimental.globalNotFound: falsebutapp/global-not-found.tsxstill ondisk, it still spins. The file's presence alone seems sufficient.
notFound()call from inside a matched route group renders its group'snot-found.tsxat 0% CPU.Confirming the "any import" trigger
Reducing
app/global-not-found.tsxto zero imports fixes it completely (0% CPU). I then tested the import kinds separately:global-not-found.tsxcontentsimport "./globals.css"next/link, local constants,import type { Metadata }) — no CSSSo it is not CSS-specific; any import edge appears to do it, matching the issue title.
Native stack
sampleon the spinning process shows the time is essentially all in the native binary, with spin-yield behavior rather than blocking:(
cthread_yield/swtch_pri= busy spin-yield loop, not a blocked wait.)Version matrix
To rule out anything app-specific, I built a minimal repro following the steps in the OP — two route groups, no root layout,
globalNotFound: true,global-not-found.tsxwithimport "./globals.css"— and ran the same probe against each version:16.2.1016.2.11(current stable)16.3.0-preview.9So the latest stable patch does not include the fix, but something on the 16.3 line resolves it.
Workarounds for anyone hitting this on 16.2.x
next dev --webpack— 0% CPU, no source changes, keeps the styled 404. Slower dev compiles.global-not-found.tsx— keeps Turbopack, but the page loses stylesheets,next/link, and any importedconstants.
Production builds are unaffected either way.
Address the CodeRabbit review of PR #32
Add a pass-through root layout
fix(404): mostrar la página del sitio en vez del 404 crudo de Next
fix(404): mostrar la página del sitio en vez del 404 crudo de Next (#6)
feat: new Cognera site with products, references, English version and…
icyJoseph commentedon Nov 14, 2026
We couldn't really reproduce, and community reports claim 16.3 fixed it for them who experienced it.
github-actions commentedon Nov 28, 2026
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.