From 6e7ce4bbe267336a00346101f42ad4eb05285dac Mon Sep 17 00:00:00 2001 From: Remy Sharp Date: Sun, 31 Dec 2017 16:23:07 +0000 Subject: [PATCH] fix: swallow child.stdin err This is a weird case where stdin isn't fully connected and throws in ubuntu 16.04 (replicated in a Docker image). Fixes #1195 --- lib/monitor/run.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/monitor/run.js b/lib/monitor/run.js index ba5c2e32..0e9a6440 100644 --- a/lib/monitor/run.js +++ b/lib/monitor/run.js @@ -67,7 +67,6 @@ function run(options) { var args = runCmd ? utils.stringify(executable, cmd.args) : ':'; var spawnArgs = [sh, [shFlag, args]]; - debug('spawning', args); if (utils.version.major === 0 && utils.version.minor < 8) { // use the old spawn args :-\ @@ -95,10 +94,15 @@ function run(options) { env: env, stdio: stdio, }); + utils.log.detail('forking'); + debug(forkArgs); } else { + utils.log.detail('spawning'); child = spawn.apply(null, spawnArgs); + debug(spawnArgs); } + if (config.required) { var emit = { stdout: function (data) { @@ -257,6 +261,10 @@ function run(options) { process.stdin.resume(); // FIXME decide whether or not we need to decide the encoding // process.stdin.setEncoding('utf8'); + + // swallow the stdin error if it happens + // ref: /~https://github.com/remy/nodemon/issues/1195 + child.stdin.on('error', () => {}); process.stdin.pipe(child.stdin); bus.once('exit', function () {