joyent/node — Issue #2127: child_process.spawn doesn't callback with certain scripts
Author: timmolendijk
Created: 2011-11-16 04:29:05+00:00
State: open

Run the following simple script (`testscript.js`) from the command line:

var spawn = require('child_process').spawn;
var watch = spawn('compass', ['watch', '--poll', '--boring']);
watch.stdout.on('data', function(data) {
console.log('stdout: ' + data);
});
watch.stderr.on('data', function(data) {
console.error('stderr: ' + data);
});

It calls `compass`, which is an executable that comes with [Compass](http://compass-style.org/). Install it and create an environment for it to run, then execute the Node script:

gem install compass
compass create testproject
cd testproject
node testscript.js

You will notice that `watch`'s callbacks never get called, even though the spawning has been succesful and the compass script is running properly. If you try `compass compile` instead you will notice that it sort of works, although it will swallow half of the output.

I guess `compass` must be doing some trickery internally, but if you run it from the command line it works perfectly fine. So that's what makes me think that Node's behavior here is not correct.

More details in [this report at the Compass tracker](https://github.com/chriseppstein/compass/issues/619).