mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2026-08-23 23:02:17 +10:00
fix(server): log unhandled rejections instead of crashing the process
Node 24 terminates the whole process on an unhandled promise rejection, so a single request's stray rejection could take the server down for every user (as the USER_STOPPED agent-abort bug did). Add a process-level unhandledRejection handler that logs and keeps serving. Uncaught exceptions are intentionally left on Node's default crash-and-restart, since process state is unsafe afterward. Claude-Session: https://claude.ai/code/session_01ULhhLQ24DvnYwzP4afDuye
This commit is contained in:
@@ -10,6 +10,14 @@ export { createApp } from "./http/app";
|
|||||||
async function main() {
|
async function main() {
|
||||||
await runStartupChecks();
|
await runStartupChecks();
|
||||||
|
|
||||||
|
// Safety net: Node 24 crashes the whole process on an unhandled rejection. One request's
|
||||||
|
// stray promise must not take the server down for everyone, so log and keep serving.
|
||||||
|
// Registered after startup checks so a broken startup still fails loudly. (Left uncaught
|
||||||
|
// exceptions on Node's default crash-and-restart, since process state is unsafe after one.)
|
||||||
|
process.on("unhandledRejection", (reason) => {
|
||||||
|
console.error("[unhandledRejection]", reason);
|
||||||
|
});
|
||||||
|
|
||||||
const port =
|
const port =
|
||||||
process.env.NODE_ENV === "production" ? Number.parseInt(process.env.PORT ?? "3000", 10) : env.SERVER_PORT;
|
process.env.NODE_ENV === "production" ? Number.parseInt(process.env.PORT ?? "3000", 10) : env.SERVER_PORT;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user