Instrumentation hook is not called in standalone output
Open
@icyJoseph is already working on this.
Since Jun 30, 2025.
- Dominant language
- JavaScript
- Stars
- 142k
- Forks
- 32.4k
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 351
Description
Link to the code that reproduces this issue
https://github.com/AOEChamp/nextjs-standalone-instrumentation-bug
To Reproduce
npm run build
node .next/standalone/server.js
Current vs. Expected behavior
Standalone build run will pickup the instrumentation.ts from the src directory and print "instrumentation SRC." If the instrumentation.ts is not in the src directory, it will not run. npm run dev works correctly with the root instrumentation. This is confusing and not clearly explained in the docs: https://nextjs.org/docs/app/guides/instrumentation
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 23.6.0: Thu Mar 6 21:58:56 PST 2025; root:xnu-10063.141.1.704.6~1/RELEASE_ARM64_T6020
Available memory (MB): 65536
Available CPU cores: 12
Binaries:
Node: 22.14.0
npm: 10.9.2
Yarn: N/A
pnpm: N/A
Relevant Packages:
next: 15.3.4 // Latest available version is detected (15.3.4).
eslint-config-next: 15.3.4
react: 19.1.0
react-dom: 19.1.0
typescript: 5.8.3
Next.js Config:
output: standalone
Which area(s) are affected? (Select all that apply)
Not sure
Which stage(s) are affected? (Select all that apply)
next build (local)
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.