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:
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 next@16.1.6
- Broken in next@16.2.1 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.
Link to the code that reproduces this issue
https://github.com/intoRandom/next-global-not-found-import-bug
To Reproduce
Current vs. Expected behavior
Expected:
Actual:
Key finding:
The issue is triggered by any import inside global-not-found.tsx.
Working version (no imports, same HTML structure):
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:
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.