[Next14] Scripts in Root Layout are not included in error.js
Page
#76264
Labels
Error Handling
Related to handling errors (e.g., error.tsx, global-error.tsx).
Script (next/script)
Related to Next.js Script Optimization.
Link to the code that reproduces this issue
https://github.com/HuriHuchi/next-issue-report
To Reproduce
npm run dev
)app/layout.tsx
) with and inline script to initializewindow.__ENV
app/error.tsx
file to handle errors at the root levelwindow.__ENV
Current vs. Expected behavior
Expected Behavior
app/error.tsx
present, the Root Layout (app/layout.tsx
) should remain intact, and its scripts (e.g., the inline script initializing window.__ENV) should execute, making window.__ENV available in the browser (e.g., console.log(window.__ENV) outputs { API_KEY: "test", ENV: "development" }).app/error.tsx
, preventing propagation to the global error boundary, and the Root Layout’s structure should be preserved.Actual Behavior
app/error.tsx
being defined.window.__ENV
is not initialized (console.log(window.__ENV)
returnsundefined
).Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 24.3.0: Thu Jan 2 20:24:24 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T6030 Available memory (MB): 36864 Available CPU cores: 12 Binaries: Node: 20.14.0 npm: 10.8.2 Yarn: 1.22.22 pnpm: N/A Relevant Packages: next: 15.2.0-canary.66 // Latest available version is detected (15.2.0-canary.66). eslint-config-next: N/A react: 19.0.0 react-dom: 19.0.0 typescript: 5.7.3 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
Not sure
Which stage(s) are affected? (Select all that apply)
next dev (local)
Additional context
Why is this happening? Is this intended behavior?
The text was updated successfully, but these errors were encountered: