Next.js instrumentation.ts not executing
macadev
HOBBYOP

a year ago

Hi, I have a next.js 15.1.7 project on railway. Next has a feature to execute a function once on startup via file called instrumentation.ts - see their docs: https://nextjs.org/docs/app/building-your-application/optimizing/instrumentation

My logic in instrumentation.ts runs fine locally, but it doesn't seem to fire on Railway. I have added console.log statements to debug and checked network stats but don't see it executing.

Is there something about railway that causes that feature to not be supported? Thank for the help.

Solved

3 Replies

brody
EMPLOYEE

a year ago

Hello,

I'm no NextJS expert but it sounds like you would want to use a pre-deploy command to run that file when on Railway -

https://docs.railway.com/guides/pre-deploy-command

But regardless, this sounds like a Vercel specific feature that they boostrap to work locally as well, you may need to look for alternative methods to run the functions when deployed to Railway.

Best,
Brody


Status changed to Awaiting User Response Railway 12 months ago


macadev
HOBBYOP

a year ago

Thanks for the response. I think you are wrong that this is a Vercel feature. I figured out the problem - I just didn't place instrumentation.ts inside the src/ folder like the docs say. I placed it in the root of the project which is supposed to also work according to the docs, but it didn't.


Status changed to Awaiting Railway Response Railway 12 months ago


brody
EMPLOYEE

a year ago

I definitely could be wrong, I'm no NextJS expert after all!

Perhaps better logging could help you track down the issue?


Status changed to Awaiting User Response Railway 12 months ago


Railway
BOT

6 months ago

This thread has been marked as solved automatically due to a lack of recent activity. Please re-open this thread or create a new one if you require further assistance. Thank you!

Status changed to Solved Railway 6 months ago


Loading...