79546233

Date: 2025-03-31 12:36:54
Score: 1
Natty:
Report link

looks like your uncaughtException handler isn't catching the error because nodemon restarts the server before the handler runs.

Try running your server with plain node: node server.js

If this works, then nodemon is the issue. You can prevent it from restarting on uncaught exceptions by adding this

to nodemon.json

{ "restartable": "rs", "ignore": ["node_modules/**"], "env": { "NODE_ENV": "development" }, "ext": "js,json" }

another thing to check is whether console.log(x) runs before process.on('uncaughtException') is set up. If app.js is imported before the handler, the error might occur before it's caught.

Try putting console.log(x) inside server.js after the handler and see if it works.

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (1):
Posted by: thepatv2