From c986218c3a98564e38d68689150b33a6aa6c4b3a Mon Sep 17 00:00:00 2001 From: erin Date: Tue, 12 Dec 2017 13:19:33 -0600 Subject: [PATCH] Improve error handling in streaming/index.js (#5968) On an unhandled worker exception, we should log the exception and exit with nonzero status, instead of letting workers silently fail and restarting them in an endless loop. Note: we previously tried to handle the `'error'` signal. That's not a signal Node fires; my patch traps `'uncaughtException'`, which is what the code was _trying_ to do. --- streaming/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/streaming/index.js b/streaming/index.js index 31c597cf0..198eac1ae 100644 --- a/streaming/index.js +++ b/streaming/index.js @@ -563,12 +563,14 @@ const startWorker = (workerId) => { const onError = (err) => { log.error(err); + server.close(); + process.exit(0); }; process.on('SIGINT', onExit); process.on('SIGTERM', onExit); process.on('exit', onExit); - process.on('error', onError); + process.on('uncaughtException', onError); }; throng({