nextjs - ✅(Solved) Fix Next.js standalone output does not run Node.js instrumentation code [1 pull requests, 4 comments, 3 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#89377Fetched 2026-04-08 02:02:57
View on GitHub
Comments
4
Participants
3
Timeline
19
Reactions
1
Author
Timeline (top)
subscribed ×8commented ×4labeled ×3mentioned ×2

Fix Action

Fixed

PR fix notes

PR #89385: fix: run Node instrumentation when using standalone server

Description (problem / solution / changelog)

What?

  • Fixes Node.js instrumentation not running in standalone mode.

Why?

  • Standalone server bypasses NextNodeServer.prepareImpl() where instrumentation is registered.

How?

  • Register instrumentation in router-server.ts initialize() for production mode.

Closes NEXT- fixes: #89377

Changed files

  • packages/next/src/server/lib/router-server.ts (modified, +5/-0)

Code Example

> turbopack-test@0.1.0 dev /home/XXX/work/turbopack-test
> next dev

Next.js 16.2.0-canary.23 (Turbopack)
- Local:         http://localhost:3000
- Network:       http://10.255.255.254:3000
Ready in 288ms
Registering instrumentation... nodejs
Node.js runtime detected
🚀 ~ register ~ globalThis._instrumentation_registered: true
Instrumentation successfully registered. true

---

> turbopack-test@0.1.0 start
> next start

Next.js 16.2.0-canary.23
- Local:         http://localhost:3000
- Network:       http://10.255.255.254:3000
Ready in 114ms
"next start" does not work with "output: standalone" configuration. Use "node .next/standalone/server.js" instead.
Registering instrumentation... nodejs
Node.js runtime detected
🚀 ~ register ~ globalThis._instrumentation_registered: true
Instrumentation successfully registered. true

---

Next.js 16.2.0-canary.23
- Local:         http://localhost:3000
- Network:       http://0.0.0.0:3000
Ready in 0ms

---

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Thu Jun  5 18:30:46 UTC 2025
  Available memory (MB): 58254
  Available CPU cores: 20
Binaries:
  Node: 22.18.0
  npm: 10.9.3
  Yarn: 1.22.22
  pnpm: 10.15.1
Relevant Packages:
  next: 16.2.0-canary.23 // Latest available version is detected (16.2.0-canary.23).
  eslint-config-next: N/A
  react: 19.2.3
  react-dom: 19.2.3
  typescript: 5.9.3
Next.js Config:
  output: standalone
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/yunsii/turbopack-test

To Reproduce

  1. npm install
  2. npm run dev
  3. Observe console output (see "Current vs. Expected behavior")
  4. npm run build
  5. npm run start
  6. Observe console output (see "Current vs. Expected behavior")
  7. node .next/standalone/server.js
  8. Observe console output (see "Current vs. Expected behavior")

Current vs. Expected behavior

Expected behavior (next dev)

> turbopack-test@0.1.0 dev /home/XXX/work/turbopack-test
> next dev

▲ Next.js 16.2.0-canary.23 (Turbopack)
- Local:         http://localhost:3000
- Network:       http://10.255.255.254:3000
✓ Ready in 288ms
Registering instrumentation... nodejs
Node.js runtime detected
🚀 ~ register ~ globalThis._instrumentation_registered: true
Instrumentation successfully registered. true

Expected behavior (next start)

> turbopack-test@0.1.0 start
> next start

▲ Next.js 16.2.0-canary.23
- Local:         http://localhost:3000
- Network:       http://10.255.255.254:3000
✓ Ready in 114ms
"next start" does not work with "output: standalone" configuration. Use "node .next/standalone/server.js" instead.
Registering instrumentation... nodejs
Node.js runtime detected
🚀 ~ register ~ globalThis._instrumentation_registered: true
Instrumentation successfully registered. true

Current behavior (node .next/standalone/server.js)

▲ Next.js 16.2.0-canary.23
- Local:         http://localhost:3000
- Network:       http://0.0.0.0:3000
✓ Ready in 0ms

Issue: node .next/standalone/server.js does not run any instrumentation code. The instrumentation code cannot be found in the standalone directory.

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Thu Jun  5 18:30:46 UTC 2025
  Available memory (MB): 58254
  Available CPU cores: 20
Binaries:
  Node: 22.18.0
  npm: 10.9.3
  Yarn: 1.22.22
  pnpm: 10.15.1
Relevant Packages:
  next: 16.2.0-canary.23 // Latest available version is detected (16.2.0-canary.23).
  eslint-config-next: N/A
  react: 19.2.3
  react-dom: 19.2.3
  typescript: 5.9.3
Next.js Config:
  output: standalone

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

Instrumentation, Output, Runtime

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

next build (local), next dev (local)

Additional context

  • Using output: "standalone" configuration for the build.
  • Issue only occurs when running node .next/standalone/server.js. Both next dev and next start work correctly.

extent analysis

TL;DR

The instrumentation code is not being executed when running node .next/standalone/server.js due to the output: "standalone" configuration.

Guidance

  • Verify that the instrumentation code is correctly configured and imported in the next.config.js file.
  • Check the next.config.js file for any conditional logic that might be preventing the instrumentation code from being included in the standalone build.
  • Investigate the differences in the build process between next dev, next start, and node .next/standalone/server.js to understand why the instrumentation code is not being executed in the standalone mode.
  • Consider modifying the next.config.js file to include the instrumentation code in the standalone build, or use a different configuration for the standalone build.

Example

No code example is provided as the issue is related to the configuration and build process, and not a specific code snippet.

Notes

The issue seems to be related to the output: "standalone" configuration, which might be excluding the instrumentation code from the build. The fact that next dev and next start work correctly suggests that the issue is specific to the standalone build process.

Recommendation

Apply a workaround by modifying the next.config.js file to include the instrumentation code in the standalone build, as the root cause of the issue is likely related to the configuration and build process.

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