global-not-found breaks with any import (infinite dev loop, high CPU) in Next 16.2.x
Link to the code that reproduces this issue
https://github.com/intoRandom/next-global-not-found-import-bug
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.
Thank you for reporting this issue and providing the reproduction repository.
On Thu, Apr 2, 2026, 7:49 AM intoRandom @.***> wrote:
intoRandom created an issue (vercel/next.js#92256) https://github.com/vercel/next.js/issues/92256 Link to the code that reproduces this issue
https://github.com/intoRandom/next-global-not-found-import-bug To Reproduce
1.
Create a new Next.js app: pnpm create @.*** 2.
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 3.
Remove root layout and page: rm app/page.tsx app/layout.tsx 4.
Enable experimental flag in next.config.ts: export default { experimental: { globalNotFound: true, }, } 5.
Create app/global-not-found.tsx with an import: import './globals.css';
export default function GlobalNotFound() { return (
404 - Page Not Found
This page does not exist.
); }
6.
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 (
404 - Page Not Found
This page does not exist.
); }
Provide environment information
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 @.***
Broken in @.*** 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.
— Reply to this email directly, view it on GitHub https://github.com/vercel/next.js/issues/92256?email_source=notifications&email_token=B67D5GOAAKQQFLYUYZT35O34TZOW3A5CNFSL4Z3JMQ5C6L3HNF2C22DVMIXUS43TOVSS6NBRHE2DGNZYGIZDRJTSMVQXG33OVJZXKYTTMNZGSYTFMSSWK5TFNZ2KYZTPN52GK4S7MNWGSY3L, or unsubscribe https://github.com/notifications/unsubscribe-auth/B67D5GJXY2XEBB2AOAIF5Y34TZOW3AVCNFSM6AAAAACXKRT53OVHI2DSMVQWIX3LMV43ASLTON2WKOZUGE4TIMZXHAZDEOA . You are receiving this because you are subscribed to this thread.Message ID: @.***>
btop has captured this bug well for me (M4 Pro, 64GB). It's absolutely thrashing the CPU, and Next.js is spreading it across all cores.
@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.
Another reproduction: this also hits the stable not-found.tsx (no experimental.globalNotFound, root layout present) on 16.2.7
Since @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, no experimental.globalNotFound, and a normal root app/layout.tsx present. That suggests the problem is in how the not-found special entry is handled in the module graph generally, not just global-not-found.
Environment
[email protected],react/[email protected]- Windows 11, 32 logical cores
- Default Turbopack dev server (
next dev) - Plain config: no
experimental.globalNotFound, rootapp/layout.tsxexists
Symptom
- With zero requests in flight, the dev server idles at ~50% CPU (16 of 32 cores pegged) indefinitely.
- The only thing changing on disk during that idle is the not-found server chunk:
.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.tsx imports |
Idle CPU | not-found chunk |
|---|---|---|
only next/link |
0% | stable, no recompile |
a large shared "workspace chrome" component (transitively pulls in most of the app: sidebar, tabs, an editor surface, a terminal, overlays, a status bar, dozens of "use client" components + their deps) |
~50% | recompiles every ~5s in a loop |
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
- Scaffold a fresh App Router + TS app, then pin
[email protected],[email protected],[email protected]. - Keep the default root
app/layout.tsx. Do not setexperimental.globalNotFound. - Add
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.
@chcaru does this still happen with next@preview?
Problem reproduction in version 16.2.9: Next.js is mining cryptocurrency on my computer.
I am encountering the same issue as well. Below is the config
next.config.ts
import "./src/env.js";
import type { NextConfig } from "next";
const nextConfig: NextConfig = {
reactCompiler: true,
experimental: {
globalNotFound: true,
},
images: {
remotePatterns: [
{
protocol: "https",
hostname: "lh3.googleusercontent.com",
},
],
},
};
export default nextConfig;
package.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"]
}
- project is created using create-t3-app and migrated to next 16 manually.
- includes dependencies for Prisma, TRPC and Shadcn UI (base UI)
- In
global-not-found.tsx, using"use client"directive or importing any component or dependency (importingglobal.csstoo) causes the CPU and RAM to spike
Confirming this on 16.2.10 and 16.2.11, and reporting that it appears fixed in 16.3.0-preview.9.
Adding measurements in case they help narrow it down — the headline is that a single curl to an unmatched URL pins ~8 cores
indefinitely, and the 404 response itself is fast, so the spin is background work that never terminates.
Environment
Platform: darwin arm64 (macOS 26.5.2), 10 cores, 32 GB
Node: v24.17.0
pnpm: 11.17.0
next: 16.2.10 (also reproduced on 16.2.11)
react / react-dom: 19.2.7
Config: experimental.globalNotFound: true, turbopackFileSystemCacheForDev: false
App shape matches the repro: two route groups (app/(storefront), app/(admin)), no root layout, and an app/global-not-found.tsx
with imports.
Symptom
One curl to an unmatched path, then sampling next-server CPU:
GET /this-route-does-not-exist 404 in 238ms (next.js: 171ms, proxy.ts: 5ms, application-code: 62ms)
t+03s cpu=237.9%
t+06s cpu=730.0%
t+09s cpu=755.3%
...
t+45s cpu=802.4%
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:
| Variant | Result |
|---|---|
| Idle / valid page request | 0% |
notFound() from a matched route in a group (/tags/bogus) |
0% — clean |
Unmatched URL, experimental.globalNotFound: false |
still spins (~795%) |
Unmatched URL, path bypassing the middleware matcher (/nope.png) |
still spins (~880%) |
next dev --disable-source-maps |
still spins (~797%) |
next dev --webpack |
0% |
Production (next build && next start) |
0% |
Two things worth calling out:
- It is not gated on the
globalNotFoundflag. Withexperimental.globalNotFound: falsebutapp/global-not-found.tsxstill on disk, it still spins. The file's presence alone seems sufficient. - It only affects genuinely unmatched URLs. A
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.tsx to zero imports fixes it completely (0% CPU). I then tested the import kinds separately:
global-not-found.tsx contents |
CPU |
|---|---|
| No imports at all | 0% |
Only import "./globals.css" |
~765% |
Only JS/TS imports (next/link, local constants, import type { Metadata }) — no CSS |
~830% |
So it is not CSS-specific; any import edge appears to do it, matching the issue title.
Native stack
sample on the spinning process shows the time is essentially all in the native binary, with spin-yield behavior rather than blocking:
10277 next-swc.darwin-arm64.node ???
2328 libsystem_pthread.dylib thread_start
2305 CoreFoundation __CFRunLoopRun
357 libsystem_pthread.dylib cthread_yield
357 libsystem_kernel.dylib swtch_pri
(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.tsx with import "./globals.css" — and ran the same probe against each version:
| Version | Result |
|---|---|
16.2.10 |
reproduces (~590%) |
16.2.11 (current stable) |
reproduces (~590%) |
16.3.0-preview.9 |
fixed — 0%, cputime 0:03.98 |
So 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.- Remove all imports from
global-not-found.tsx— keeps Turbopack, but the page loses stylesheets,next/link, and any imported constants.
Production builds are unaffected either way.
We couldn't really reproduce, and community reports claim 16.3 fixed it for them who experienced it.
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.