Prevented "write after end" SVR.JS crashes (again)
This commit is contained in:
parent
6e882fdbc8
commit
f3fb1f928a
1 changed files with 7 additions and 3 deletions
10
index.js
10
index.js
|
@ -196,7 +196,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 && !emulatedStdout.endEmitted) {
|
||||
if (emulatedStdout._readableState && emulatedStdout._readableState.flowing !== null && !emulatedStdout.endEmitted) {
|
||||
emulatedStdout.on("end", function() {
|
||||
emulatedStderr.push(null);
|
||||
eventEmitter.emit("error", err);
|
||||
|
@ -207,7 +207,7 @@ function createFastCGIHandler(options) {
|
|||
}
|
||||
} else {
|
||||
emulatedStdout.push(null);
|
||||
if (emulatedStdout._readableState && emulatedStdout._readableState.length > 0 && emulatedStdout._readableState.flowing !== null && !emulatedStdout.endEmitted) {
|
||||
if (emulatedStdout._readableState && emulatedStdout._readableState.flowing !== null && !emulatedStdout.endEmitted) {
|
||||
emulatedStdout.on("end", function() {
|
||||
emulatedStderr.push(null);
|
||||
eventEmitter.emit("exit", appStatus, null);
|
||||
|
@ -470,6 +470,10 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e
|
|||
}
|
||||
});
|
||||
|
||||
res.on("close", function() {
|
||||
if(handler.stdout) handler.stdout.unpipe(res); //Prevent server crashes with write after the end
|
||||
});
|
||||
|
||||
function handlerConnection() {
|
||||
handler.init();
|
||||
handler.stdout.on("data", dataHandler);
|
||||
|
@ -493,7 +497,7 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e
|
|||
serverconsole.errmessage(preparedStderr);
|
||||
}
|
||||
handler.stdout.unpipe(res); //Prevent server crashes with write after the end
|
||||
res.end();
|
||||
if(!res.finished) res.end();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue