3 months 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.
3 Replies
3 months 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[bot] • 3 months ago
3 months 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[bot] • 3 months ago
3 months 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[bot] • 3 months ago