From b3ed3d0379f8c26b88bfe762b8f9df5cf48ff158 Mon Sep 17 00:00:00 2001 From: Anthony Laibe Date: Thu, 16 Aug 2018 15:01:48 +0100 Subject: [PATCH] Do not hang if process crash --- lib/core/processes/processLauncher.js | 4 ++++ lib/core/processes/processWrapper.js | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/lib/core/processes/processLauncher.js b/lib/core/processes/processLauncher.js index 418cb1dbd..2dc0b00ca 100644 --- a/lib/core/processes/processLauncher.js +++ b/lib/core/processes/processLauncher.js @@ -29,6 +29,10 @@ class ProcessLauncher { _subscribeToMessages() { const self = this; this.process.on('message', (msg) => { + if (msg.error) { + self.logger.error(msg.error); + process.exit(0); + } if (msg.result === constants.process.log) { return self._handleLog(msg); } diff --git a/lib/core/processes/processWrapper.js b/lib/core/processes/processWrapper.js index d65350422..3b934a106 100644 --- a/lib/core/processes/processWrapper.js +++ b/lib/core/processes/processWrapper.js @@ -1,3 +1,7 @@ +process.on('uncaughtException', function(e){ + process.send({error: e.stack}); +}); + const constants = require('../../constants'); const Events = require('./eventsWrapper');