-
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
Instrumentation.js gets called 3 times #51450
Comments
Even when using global variables to store the invoke condition, doesn't seem to work. Global variables seem to get completely wiped.
That printed this
|
Having the same issue using the app router. It seems global variables are wiped, so I can't know if the instrumentation has been called yet |
+1, having the same issue. For me it's without the app router but the traditional one. |
+1, having the same issue. |
1 similar comment
+1, having the same issue. |
Hey I couldn't repro this based on the latest canary. is there a reproduction based on the latest canary that you can provide? Thanks |
This comment has been minimized.
This comment has been minimized.
Having the same issue for nextjs: 13.4.13. |
Is there a way to add another hook that will be called AFTER bootstrapping/setting env and wiping out globals? Would love to see the ability to patch mods and set globals. |
@huozhi It runs twice if |
@matejfalat did you find a way to bypass this behavior ? I face the exact same issue |
Having the same issue for next 14.0.3 |
From the instrumentation docs:
export async function register() {
if (process.env.NEXT_RUNTIME === 'nodejs') {
await import('./instrumentation-node')
}
if (process.env.NEXT_RUNTIME === 'edge') {
await import('./instrumentation-edge')
}
} Middleware is running based on edge runtime and page is on nodejs runtime, you could use above code to separate the instrumentation |
@huozhi Yes thats true but in the example
|
@matejfalat you are right the middleware seems to cause the second register for some reason |
Verify canary release
Provide environment information
btw Windows version is 11 Home. Not sure why
next info
isn't able to identify that.Which area(s) of Next.js are affected? (leave empty if unsure)
App directory (appDir: true)
Link to the code that reproduces this issue or a replay of the bug
/
To Reproduce
instrumentaion.js
as per the guide https://nextjs.org/docs/app/building-your-application/optimizing/instrumentationconsole.log
in theregister
functionnpm run build
npm start
There should be 2-3
console.log
s, seeminglyregister
function gets called multiple times.Describe the Bug
register
function ofinstrumentation.js
gets called multiple times. 3 times in Azure Web Services. 2 times locally.Azure App Service logs
Expected Behavior
register
function should be called only once.Which browser are you using? (if relevant)
Chrome latest
How are you deploying your application? (if relevant)
Azure App Services - Linux Single Container but the issue happens locally too.
NEXT-1600
The text was updated successfully, but these errors were encountered: