kopia lustrzana https://github.com/c9/core
Fix vfs-child/parent error handling
Fixes crash when child prints to stdout/stderr, triggering unhandled EPIPE errorpull/117/merge
rodzic
8723eca18f
commit
31218bbc1d
|
@ -23,17 +23,22 @@ function Parent(fsOptions) {
|
|||
// Override Consumer's connect since the transport logic is internal to this module
|
||||
this.connect = connect.bind(this);
|
||||
function connect(callback) {
|
||||
child = spawn(nodeBin[0], args, options);
|
||||
try {
|
||||
child = spawn(nodeBin[0], args, options).on("error", tryNext);
|
||||
}
|
||||
catch (e) {
|
||||
return tryNext(e);
|
||||
}
|
||||
child.stdin.readable = true;
|
||||
Consumer.prototype.connect.call(this, [child.stdout, child.stdin], tryNext);
|
||||
child.on("exit", disconnect);
|
||||
child.on("error", tryNext);
|
||||
child.stdin.resume();
|
||||
var _self = this;
|
||||
// try all possible locations of node before giving up
|
||||
function tryNext(err, vfs) {
|
||||
if (!child) return;
|
||||
child.removeListener("error", tryNext);
|
||||
child.on("error", function ignore() {});
|
||||
if (err && err.code == "ENOENT" && nodeBin.length > 1) {
|
||||
child = null;
|
||||
nodeBin.shift();
|
||||
|
|
Ładowanie…
Reference in New Issue