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
12
index.js
12
index.js
|
@ -168,7 +168,11 @@ function createFastCGIHandler(options) {
|
|||
if (processedPacket.type == STDOUT) {
|
||||
if(processedPacket.content.length > 0) emulatedStdout.push(processedPacket.content);
|
||||
} else if (processedPacket.type == STDERR) {
|
||||
if(processedPacket.content.length > 0) emulatedStderr.push(processedPacket.content);
|
||||
try {
|
||||
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) {
|
||||
if (typeof socket !== "undefined") socket.removeListener("data", fastCGISocketHandler);
|
||||
var appStatus = processedPacket.content.readUInt32BE(0);
|
||||
|
@ -185,22 +189,24 @@ function createFastCGIHandler(options) {
|
|||
err = new Error("Multiplexed connections not supported by the FastCGI application");
|
||||
}
|
||||
emulatedStdout.push(null);
|
||||
emulatedStderr.push(null);
|
||||
if (emulatedStdout._readableState && emulatedStdout._readableState.length > 0 && emulatedStdout._readableState.flowing !== null) {
|
||||
emulatedStdout.on("end", function() {
|
||||
emulatedStderr.push(null);
|
||||
eventEmitter.emit("error", err);
|
||||
});
|
||||
} else {
|
||||
emulatedStderr.push(null);
|
||||
eventEmitter.emit("error", err);
|
||||
}
|
||||
} else {
|
||||
emulatedStdout.push(null);
|
||||
emulatedStderr.push(null);
|
||||
if (emulatedStdout._readableState && emulatedStdout._readableState.length > 0 && emulatedStdout._readableState.flowing !== null) {
|
||||
emulatedStdout.on("end", function() {
|
||||
emulatedStderr.push(null);
|
||||
eventEmitter.emit("exit", appStatus, null);
|
||||
});
|
||||
} else {
|
||||
emulatedStderr.push(null);
|
||||
eventEmitter.emit("exit", appStatus, null);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue