I'm dealing with a bizarre bug in my full-stack project (Node.js/Express/Prisma backend, vanilla JS frontend). My server keeps crashing and restarting every 30 seconds, triggered by a periodic save-game API call from the client. The issue is that it terminates without any error messages - no `try/catch`, `uncaughtException`, or `unhandledRejection` handlers are catching anything, leaving me clueless about what's going wrong. This cycle is also causing some frontend issues like CSS not loading properly, which is making some UI components unresponsive.
I finally figured out a few things:
1. Checked for client-side bugs but everything seems to be firing correctly.
2. Tried wrapping my save-game API function in a `try/catch` but it didn't help.
3. Added global error handlers at the start of my server file, and still, no logs appeared when it crashed.
Currently, I suspect some hidden `process.exit()` call might be the culprit, possibly in one of my dependencies like Prisma. I'm logging calls to `process.exit()` to trace it, but I'm reaching out to see if anyone has dealt with a Node.js process terminating without any logs and if my theories sound off the mark. Any ideas or insight would be greatly appreciated!
3 Answers
Glad to hear you're figuring stuff out, but it sounds like a total headache! The fact that turning off your database calls stopped the crashing means you're honing in on the right area. Updating Prisma to the latest version might resolve any known bugs you’re running into. Don't hesitate to reach out to their support if nothing seems to work. And for the failing buttons, make sure there's no conflicting code or events that might be interfering - it can be as sneaky as a misplaced comma sometimes!
It sounds like you've really gone through the wringer with this! I think you're onto something with the `process.exit()` theory. It could definitely be buried in a dependency or library, especially if you're using Prisma with SQLite. I recommend double-checking the APIs of any third-party libraries you're using—sometimes they're not as friendly about errors. Also, if your server is managing state or using promises, a mismanaged promise could cause silent exits. Try temporarily disabling different parts of your API calls to isolate the problem further.
Have you tried using a process manager like PM2? It can help catch exits and even provide logs. Another radical solution might be to overwrite `process.exit()` with your own function. You could add logging to see when it gets called and what the stack trace looks like. It sounds a bit cumbersome, but it might just reveal the hidden culprit behind those mysterious crashes.

Related Questions
How To: Running Codex CLI on Windows with Azure OpenAI
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically