Skip to content

Commit

Permalink
fix: swallow child.stdin err
Browse files Browse the repository at this point in the history
This is a weird case where stdin isn't fully connected and throws in
ubuntu 16.04 (replicated in a Docker image).

Fixes #1195
  • Loading branch information
remy committed Dec 31, 2017
1 parent d78bf3d commit 6e7ce4b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/monitor/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 :-\
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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 () {
Expand Down

0 comments on commit 6e7ce4b

Please sign in to comment.