-
Notifications
You must be signed in to change notification settings - Fork 26.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The instrumentation hook is only called after visiting a route #59999
Comments
I arrived at this issue after knocking my head on a related problem, but which turns out to be different -- leaving comment here for other seekers. My issue was that instrumentation hooks were not running at all in a docker context (without standalone) even though they were running on
After keeping |
This is actually a pretty major bug that took me a while to debug. I had to create a copy of my next.config.js into I have no issue with running the register function for every request, but I think the running of the instrumentation should be baked into the |
This ensures that the instrumentation hook for Node.js will run immediately during `next start` instead of waiting for the first request like does it `next dev`. However, if there is a separate instrumentation hook for Edge, that will still be lazy evaluated and wait until the first request. Fixes #59999 Fixes NEXT-2738
This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Link to the code that reproduces this issue
https://github.com/daveyjones/nextjs-instrumentation-bug
To Reproduce
Current vs. Expected behavior
The
register
function should be called automatically after runningnpm run build && npm start
. You should not have to visit a route for the function to run.Verify canary release
Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 23.1.0: Mon Oct 9 21:28:12 PDT 2023; root:xnu-10002.41.9~6/RELEASE_ARM64_T8103 Binaries: Node: 20.9.0 npm: 10.2.4 Yarn: 1.22.19 pnpm: N/A Relevant Packages: next: 14.0.5-canary.29 eslint-config-next: N/A react: 18.2.0 react-dom: 18.2.0 typescript: 5.3.3 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
App Router
Additional context
This behavior is also reported in the comments of #49897 (reference). However, since #49897 is focused on
standalone
mode (which is not a factor here), I felt it was best to create a separate issue. It may be the case that resolving this issue will also resolve #49897.NEXT-2738
The text was updated successfully, but these errors were encountered: