skip to Main Content

I’m facing a tricky problem regarding app crashes in production.

I built a web app using node.js and deployed it to Railway, and I haven’t covered each edge case or each error that might occur.

In local development, if an error occurs and gets printed in the terminal, as a user I can still proceed and do any other task, I can navigate to other pages, sign in sign out, etc.

But in production, if an error occurs (same error or any other error) and gets printed in the terminal, the whole app crashes and the server goes down.

I get a nodemon app crashed message in the logs in production:

[nodemon] app crashed - waiting for file changes before starting...

Though the same exact error happens in local development but I can still proceed and use the app.

Why is the whole app crashing in production only?

Does that mean I have to cover every possible scenario otherwise the whole server goes down?

2

Answers


  1. Chosen as BEST ANSWER

    Thank you for your answers guys!

    Apparently the issue was caused by nodemon, our brother "@Ben Schröder" mentioned that Nodemon should be used in development and not in production, which solved the problem after I removed nodemon from production and ran my app using the command "node server.js" instead of previously using "nodemon server.js".


  2. Nodemon is an application that should be used exclusively for development. If you are still looking for an application to manage deployment or a way to restart when the app crashes, you could use PM2 (https://pm2.keymetrics.io/).

    I’m also referencing "https://stackoverflow.com/questions/73039058/make-nodemon-auto-restart-a-program-on-crash-without-waiting-for-file-changes-at", something similar has been answered there and maybe you’ll find more possibilities or info there.

    Anyway, about that last question….
    Yes, it’s better to fix every little error you can think of or at least write a log and do reasonable error handling…
    At the latest when the application gets bigger and you didn’t do a bit of error handling you will get errors and have no idea why the app crashed…

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search