Prevented "write after end" SVR.JS crashes
This commit is contained in:
parent
841aff67ed
commit
f0977c9319
1 changed files with 7 additions and 3 deletions
8
index.js
8
index.js
|
@ -166,7 +166,11 @@ function createFastCGIHandler(options) {
|
|||
var processedPacket = parseFastCGIPacket(packet);
|
||||
if (processedPacket.requestID != requestID) return; //Drop the packet
|
||||
if (processedPacket.type == STDOUT) {
|
||||
try {
|
||||
if(processedPacket.content.length > 0) emulatedStdout.push(processedPacket.content);
|
||||
} catch (err) {
|
||||
//STDOUT will be lost instead of crashing the server
|
||||
}
|
||||
} else if (processedPacket.type == STDERR) {
|
||||
try {
|
||||
if(processedPacket.content.length > 0) emulatedStderr.push(processedPacket.content);
|
||||
|
@ -189,7 +193,7 @@ function createFastCGIHandler(options) {
|
|||
err = new Error("Multiplexed connections not supported by the FastCGI application");
|
||||
}
|
||||
emulatedStdout.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.endEmitted) {
|
||||
emulatedStdout.on("end", function() {
|
||||
emulatedStderr.push(null);
|
||||
eventEmitter.emit("error", err);
|
||||
|
@ -200,7 +204,7 @@ function createFastCGIHandler(options) {
|
|||
}
|
||||
} else {
|
||||
emulatedStdout.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.endEmitted) {
|
||||
emulatedStdout.on("end", function() {
|
||||
emulatedStderr.push(null);
|
||||
eventEmitter.emit("exit", appStatus, null);
|
||||
|
|
Loading…
Reference in a new issue