Fix SVR.JS crashing, because the error stream has been ended.
This commit is contained in:
parent
82f41e837e
commit
841aff67ed
1 changed files with 9 additions and 3 deletions
10
index.js
10
index.js
|
@ -168,7 +168,11 @@ function createFastCGIHandler(options) {
|
||||||
if (processedPacket.type == STDOUT) {
|
if (processedPacket.type == STDOUT) {
|
||||||
if(processedPacket.content.length > 0) emulatedStdout.push(processedPacket.content);
|
if(processedPacket.content.length > 0) emulatedStdout.push(processedPacket.content);
|
||||||
} else if (processedPacket.type == STDERR) {
|
} else if (processedPacket.type == STDERR) {
|
||||||
|
try {
|
||||||
if(processedPacket.content.length > 0) emulatedStderr.push(processedPacket.content);
|
if(processedPacket.content.length > 0) emulatedStderr.push(processedPacket.content);
|
||||||
|
} catch (err) {
|
||||||
|
//STDERR will be lost anyway...
|
||||||
|
}
|
||||||
} else if (processedPacket.type == END_REQUEST && processedPacket.content.length > 5) {
|
} else if (processedPacket.type == END_REQUEST && processedPacket.content.length > 5) {
|
||||||
if (typeof socket !== "undefined") socket.removeListener("data", fastCGISocketHandler);
|
if (typeof socket !== "undefined") socket.removeListener("data", fastCGISocketHandler);
|
||||||
var appStatus = processedPacket.content.readUInt32BE(0);
|
var appStatus = processedPacket.content.readUInt32BE(0);
|
||||||
|
@ -185,22 +189,24 @@ function createFastCGIHandler(options) {
|
||||||
err = new Error("Multiplexed connections not supported by the FastCGI application");
|
err = new Error("Multiplexed connections not supported by the FastCGI application");
|
||||||
}
|
}
|
||||||
emulatedStdout.push(null);
|
emulatedStdout.push(null);
|
||||||
emulatedStderr.push(null);
|
|
||||||
if (emulatedStdout._readableState && emulatedStdout._readableState.length > 0 && emulatedStdout._readableState.flowing !== null) {
|
if (emulatedStdout._readableState && emulatedStdout._readableState.length > 0 && emulatedStdout._readableState.flowing !== null) {
|
||||||
emulatedStdout.on("end", function() {
|
emulatedStdout.on("end", function() {
|
||||||
|
emulatedStderr.push(null);
|
||||||
eventEmitter.emit("error", err);
|
eventEmitter.emit("error", err);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
emulatedStderr.push(null);
|
||||||
eventEmitter.emit("error", err);
|
eventEmitter.emit("error", err);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
emulatedStdout.push(null);
|
emulatedStdout.push(null);
|
||||||
emulatedStderr.push(null);
|
|
||||||
if (emulatedStdout._readableState && emulatedStdout._readableState.length > 0 && emulatedStdout._readableState.flowing !== null) {
|
if (emulatedStdout._readableState && emulatedStdout._readableState.length > 0 && emulatedStdout._readableState.flowing !== null) {
|
||||||
emulatedStdout.on("end", function() {
|
emulatedStdout.on("end", function() {
|
||||||
|
emulatedStderr.push(null);
|
||||||
eventEmitter.emit("exit", appStatus, null);
|
eventEmitter.emit("exit", appStatus, null);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
emulatedStderr.push(null);
|
||||||
eventEmitter.emit("exit", appStatus, null);
|
eventEmitter.emit("exit", appStatus, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue