Skip to content

Commit 77c153b

Browse files
markliseDaniel Truong
andauthored
NRPT-301: Crash on unhandled promise rejections. (#518)
Co-authored-by: Daniel Truong <daniel@dtsoftware.ca>
1 parent ebcbc36 commit 77c153b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

api/app.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,13 @@ swaggerTools.initializeMiddleware(swaggerConfig, async function (middleware) {
8585
next();
8686
});
8787

88+
// Counterintuitively, we crash because we don't want the pod hanging around. Let's just spin up
89+
// a new pod incase the mongo topology was destroyed, among other things.
90+
process.on('unhandledRejection', function(reason) {
91+
console.log("Unhandled Rejection:", reason);
92+
process.exit(1);
93+
});
94+
8895
// Ensure uploads directory exists, otherwise create it.
8996
try {
9097
if (!fs.existsSync(UPLOAD_DIR)) {

0 commit comments

Comments
 (0)