Closed tomaszdurka closed 8 years ago
The problem is narrowed down. Currently we do
require('child-process-promise').spawn(command, commandArgs, {cwd: dir, capture: ['stdout']})
and this hangs the process. In the end it is killed by timeout. But if we add 'stderr' to 'capture':
require('child-process-promise').spawn(command, commandArgs, {cwd: dir, capture: ['stdout', 'stderr']})
then works fine. I guess it is a problem of the used thirdparty child-process-promise
. Should I prepare a quick fix with stderr
or dig deeper to the root?
Ok. My previous suggestion is actually a proper solution. See more here http://stackoverflow.com/questions/20792427/why-is-my-node-child-process-that-i-created-via-spawn-hanging. Preparing a PR.
@tomaszdurka please review
Ok. Quick question, did you actually reproduced it? As I am not sure :)
Yep. Here is my playground. You can reverify.
var fs = require('fs');
var path = require('path');
var spawn = require('./child-process-promise').spawn;
var Promise = require('bluebird');
var rimraf = require('rimraf');
var command;
//var commandText = 'sleep 5';
var commandText = 'echo hello';
//var commandText = 'echo foo 1>&2';
//var commandText = 'lame ./delete/sample.wav ./delete/sample.mp3';
var commandArgs = [];
if (commandText.indexOf(' ') >= 0) {
var commandParts = commandText.split(' ');
command = commandParts.shift();
commandArgs = commandParts;
}
var options = {
cwd: __dirname,
capture: ['stdout']
};
return spawn(command, commandArgs, options)
.progress(function(childProcess) {
/*
console.log('[spawn] childProcess.pid: ', childProcess.pid);
childProcess.stdout.on('data', function(data) {
console.log('[spawn] stdout: ', data.toString());
});
*/
//childProcess.stderr.on('data', function(data) {
// console.log('[spawn] stderr: ', data.toString());
//});
})
.then(function(result) {
//console.log('done', result.stdout.toString);
return result.stdout.toString();
})
.fail(function(err) {
console.error('ERROR: ', err);
})
//.catch(function(err) {
// console.error('ERROR: ', err);
//});
I can send to you the sample.wav
but it breaks on simple echo
too.
lgtm
As investigated: looks like lame is exhausting node.js' STDERR buffer?