Skip to content

Commit

Permalink
fix: log and exit on unhandled promise rejection
Browse files Browse the repository at this point in the history
This fixes the issue of pods not restarting on database connection errors. It will also provide
much better visibility into a variety of other unhandled promise rejections we get in Spoke.

Ref: nodejs/node#9523 (comment)
  • Loading branch information
bchrobot committed May 20, 2020
1 parent 663e6a6 commit 33faaa1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ import { r } from "./models";
import { getRunner } from "./worker";

process.on("uncaughtException", ex => {
logger.error("uncaughtException", ex);
logger.error("uncaughtException: ", ex);
process.exit(1);
});

process.on("unhandledRejection", err => {
logger.error("unhandledRejection: ", err);
process.exit(1);
});

Expand Down

0 comments on commit 33faaa1

Please sign in to comment.