nextjs - 💡(How to fix) Fix `next dev`: Instrumentation hook is still analyzed for the edge runtime despite never running in the edge runtime [5 comments, 4 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#86479Fetched 2026-04-08 02:10:44
View on GitHub
Comments
5
Participants
4
Timeline
11
Reactions
16
Timeline (top)
commented ×5labeled ×3subscribed ×2issue_type_added ×1

Error Message

  1. See the error in your console: Ecmascript file had an error 4 | console.error("Unhandled rejection:", reason); 5 | console.error("Promise:", promise); Current: There is an error logged from analysis of the instrumentation hook for edge runtimes, despite the instrumentation hook never running in the edge runtime. This error doesn't actually break anything at runtime it seems. Expected: No error should appear. With the new proxy.ts enabling a full nodejs runtime version of Next.js, the instrumentation hook never runs its "edge" version (verified via the console log in the minimal repro, the register hook only runs with process.env.NEXT_RUNTIME set to "nodejs"). Despite this, it seems like there is still some checking for nodejs-only APIs running for the instrumentation hook, which produce console warnings.

Code Example

Ecmascript file had an error
  1 | export const register = async () => {
  2 |   console.log("registering instrumentation", process.env.NEXT_RUNTIME);
> 3 |   process.on("unhandledRejection", (reason, promise) => {
    |   ^^^^^^^^^^
  4 |     console.error("Unhandled rejection:", reason);
  5 |     console.error("Promise:", promise);
  6 |   });`

---

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.6.0: Mon Aug 11 21:15:09 PDT 2025; root:xnu-11417.140.69.701.11~1/RELEASE_ARM64_T6041
  Available memory (MB): 49152
  Available CPU cores: 14
Binaries:
  Node: 22.15.1
  npm: 10.9.2
  Yarn: 1.22.22
  pnpm: N/A
Relevant Packages:
  next: 16.0.3 // Latest available version is detected (16.0.3).
  eslint-config-next: N/A
  react: 19.2.0
  react-dom: 19.2.0
  typescript: 5.9.3
Next.js Config:
  output: N/A
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/blairmcalpine/instrumentation-errors-repro

To Reproduce

  1. npm install
  2. npm run dev
  3. Visit http://localhost:3000
  4. See the error in your console:
Ecmascript file had an error
  1 | export const register = async () => {
  2 |   console.log("registering instrumentation", process.env.NEXT_RUNTIME);
> 3 |   process.on("unhandledRejection", (reason, promise) => {
    |   ^^^^^^^^^^
  4 |     console.error("Unhandled rejection:", reason);
  5 |     console.error("Promise:", promise);
  6 |   });`

Current vs. Expected behavior

Current: There is an error logged from analysis of the instrumentation hook for edge runtimes, despite the instrumentation hook never running in the edge runtime. This error doesn't actually break anything at runtime it seems.

Expected: No error should appear. With the new proxy.ts enabling a full nodejs runtime version of Next.js, the instrumentation hook never runs its "edge" version (verified via the console log in the minimal repro, the register hook only runs with process.env.NEXT_RUNTIME set to "nodejs"). Despite this, it seems like there is still some checking for nodejs-only APIs running for the instrumentation hook, which produce console warnings.

If this helps debug:

  1. notably the warnings only appear after you visit a page, and not when the initial instrumentation hook is run.
  2. It doesn't seem to produce the same warnings when using fs, but accessing the process global seems to cause problems.
  3. This only happens in dev mode, not production.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.6.0: Mon Aug 11 21:15:09 PDT 2025; root:xnu-11417.140.69.701.11~1/RELEASE_ARM64_T6041
  Available memory (MB): 49152
  Available CPU cores: 14
Binaries:
  Node: 22.15.1
  npm: 10.9.2
  Yarn: 1.22.22
  pnpm: N/A
Relevant Packages:
  next: 16.0.3 // Latest available version is detected (16.0.3).
  eslint-config-next: N/A
  react: 19.2.0
  react-dom: 19.2.0
  typescript: 5.9.3
Next.js Config:
  output: N/A

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

Instrumentation, Middleware

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

next dev (local)

Additional context

No response

extent analysis

TL;DR

The issue can be fixed by modifying the instrumentation hook to check for the NEXT_RUNTIME environment variable before accessing Node.js-only APIs.

Guidance

  • Verify that the instrumentation hook is only running in the correct runtime environment by checking the value of process.env.NEXT_RUNTIME.
  • Modify the instrumentation hook to conditionally access Node.js-only APIs based on the value of process.env.NEXT_RUNTIME.
  • Investigate why the warnings only appear after visiting a page and not during the initial instrumentation hook run.
  • Consider adding a check for the process global being available before accessing it to prevent warnings.

Example

export const register = async () => {
  console.log("registering instrumentation", process.env.NEXT_RUNTIME);
  if (process.env.NEXT_RUNTIME === 'nodejs') {
    process.on("unhandledRejection", (reason, promise) => {
      console.error("Unhandled rejection:", reason);
      console.error("Promise:", promise);
    });
  }
};

Notes

The provided example is a minimal code snippet and may need to be adapted to the actual instrumentation hook code. The issue seems to be related to the instrumentation hook accessing Node.js-only APIs in the wrong runtime environment.

Recommendation

Apply workaround: Modify the instrumentation hook to conditionally access Node.js-only APIs based on the value of process.env.NEXT_RUNTIME, as shown in the example. This should prevent the warnings from appearing in the incorrect runtime environment.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

nextjs - 💡(How to fix) Fix `next dev`: Instrumentation hook is still analyzed for the edge runtime despite never running in the edge runtime [5 comments, 4 participants]