Prevented server crash, while FastCGI service is unavailable.

This commit is contained in:
Dorian Niemiec 2024-02-21 21:21:30 +01:00
parent ea8def69d9
commit d7bae6df69

View file

@ -251,13 +251,13 @@ function createFastCGIHandler(options) {
});
function stdoutPush(data) {
var toResume = (stdoutBuffer.length == 0);
if(data === null) {
stdoutToEnd = true;
} else {
var toResume = (stdoutBuffer.length == 0);
stdoutBuffer = Buffer.concat([stdoutBuffer, Buffer.from(data)]);
if(toResume) emulatedStdout.resume();
}
if(toResume) emulatedStdout.resume();
}
var stdoutBuffer = Buffer.alloc(0);
@ -305,7 +305,7 @@ function createFastCGIHandler(options) {
var socket = net.createConnection(options, function () {
eventEmitter.emit("connect");
}).on("error", function (err) {
stdoutBuffer.push(null);
stdoutPush(null);
emulatedStderr.push(null);
eventEmitter.removeAllListeners("exit");
eventEmitter.emit("error", err);