Skip to content

A one-of-a-kind resume builder that keeps your privacy in mind. Completely secure, customizable, portable, open-source and free forever. Try it out today!

fix(server): log unhandled rejections instead of crashing the process

Amruth Pillaiefd950bd9394
diff --git a/apps/server/src/index.ts b/apps/server/src/index.ts
index 2aff6e7a3..3bf36d1b6 100644
--- a/apps/server/src/index.ts
+++ b/apps/server/src/index.ts
@@ -10,6 +10,14 @@ export { createApp } from "./http/app";
async function main() {
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 =
process.env.NODE_ENV === "production" ? Number.parseInt(process.env.PORT ?? "3000", 10) : env.SERVER_PORT;