`instrumentation.ts` `register()` function isn't getting called in Vercel preview deployment.
Unanswered
Crème D’Argent posted this in #help-forum
Crème D’ArgentOP
I have a
I have my
When I develop locally (
I've been following this GH issue around instrumentation, but it's gone somewhat stale: https://github.com/vercel/next.js/discussions/15341#discussioncomment-5845714
register() function which makes a fetch() call to a Route Handler inside of a timeout like so:export async function register() {
if (typeof window === 'undefined') {
setTimeout(async () => {
try {
await fetch('http://localhost:3000/api/boot', {
method: 'POST',
});
} catch (error) {
console.error(
`Instrumentation failed for runtime: ${process.env.NEXT_RUNTIME}`,
error
);
}
}, 500);
}
}I have my
instrumentation.ts file placed inside the /src directory, and I've enabled the experimental.instrumentationHook flag in my next.config.mjs file.When I develop locally (
next dev), the fetch call is made successfully, and if I make a console.log statement within register(), I'll see it in my terminal's output. However, once I deploy to Vercel, even though it builds correctly and the page loads successfully, there's no sign that the register() function is ever even called. No logs from within the register() function ever show up, and my Route Handler is never called.I've been following this GH issue around instrumentation, but it's gone somewhat stale: https://github.com/vercel/next.js/discussions/15341#discussioncomment-5845714
2 Replies
Crème D’ArgentOP
Seems to be related to this issue: https://github.com/vercel/next.js/issues/49897
Crème D’ArgentOP
Though I'm not sure if Vercel deploys the standalone output or not?