diff --git a/index.js b/index.js index 5ec4433..74693ed 100644 --- a/index.js +++ b/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); } } diff --git a/mod.info b/mod.info index 826e5a5..be13921 100755 --- a/mod.info +++ b/mod.info @@ -1,4 +1,4 @@ { "name": "GreenRhombus FastCGI client for SVR.JS", - "version": "1.0.1" + "version": "1.0.2" }