Error handling bugfix: pass #1

This commit is contained in:
2026-10-02 07:04:22 +01:00
parent 39a5e91eeb
commit d8ea4f8e02
53 changed files with 1179 additions and 410 deletions
+23 -2
View File
@@ -1,6 +1,27 @@
import bunextInit from "../../functions/bunext-init";
import startServer from "../../functions/server/start-server";
import { log } from "../../utils/log";
import writeErrorFile from "../../functions/write-error-file";
// Same crash contract as the dev child: log the real error, record it in the
// error file, and exit non-zero so the supervisor can restart and so the
// bundler pipeline sees the failure.
process.on("uncaughtException", (error) => {
log.error(`Uncaught exception: ${error}`);
writeErrorFile({ error, exitCode: 1, force: true });
process.exit(1);
});
process.on("unhandledRejection", (reason) => {
log.error(`Unhandled rejection: ${reason}`);
writeErrorFile({ error: reason, exitCode: 1, force: true });
process.exit(1);
});
log.info("Starting production server ...");
await bunextInit();
await startServer();
try {
await bunextInit();
await startServer();
}
catch (error) {
log.error(`Failed to start production server: ${error}`);
writeErrorFile({ error, exitCode: 1, force: true });
process.exit(1);
}