From fd09488e4be2f4dbecf2cd3b11611f5e14fd75ca Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Wed, 8 May 2019 14:41:57 -0500 Subject: [PATCH] fix(@embark/core): move process.on inside ProcessWrapper's constructor This avoids mistakenly placing process event handlers on the parent process whenever the `embark-core` package is loaded. Also, don't listen for an `'exit'` event on `process` and then call `process.exit(0)` since the event "is emitted after the child process ends" ([docs][docs]), i.e. it's unnecessary to do so and in any case it's not correct to always exit with code `0`. [docs]: https://nodejs.org/docs/latest-v10.x/api/child_process.html#child_process_event_exit --- packages/embark-core/src/processes/processWrapper.js | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/packages/embark-core/src/processes/processWrapper.js b/packages/embark-core/src/processes/processWrapper.js index 23a7cbbd8..c21216373 100644 --- a/packages/embark-core/src/processes/processWrapper.js +++ b/packages/embark-core/src/processes/processWrapper.js @@ -1,11 +1,6 @@ import { Events } from './eventsWrapper'; const constants = require('../../constants'); -process.on('uncaughtException', function(e) { - process.send({error: e.stack}); -}); - - export class ProcessWrapper { /** @@ -16,6 +11,9 @@ export class ProcessWrapper { * @param {Options} options pingParent: true by default */ constructor(options = {}) { + process.on('uncaughtException', function(e) { + process.send({error: e.stack}); + }); this.options = Object.assign({pingParent: true}, options); this.interceptLogs(); this.events = new Events(); @@ -83,7 +81,3 @@ export class ProcessWrapper { console.log('Process killed'); } } - -process.on('exit', () => { - process.exit(0); -});