Hello!
I'm trying to use this module with Express, but I'm getting some weird behavior with this peace of code:
server.on('request', function(req, res) {
req.socket._isIdle = false;
res.on('finish', function() {
req.socket._isIdle = true;
destroy(req.socket);
});
});
For some reason, req.socket._isIdle = false; takes no effect, because when I examine req.socket._isIdle in res.on('finish') function I can see it's still set to true.
But, the real problem happens here:
function destroy(socket, force) {
if (force || (socket._isIdle && isShuttingDown)) {
socket.destroy();
delete connections[socket._connectionId];
}
};
Because socket._isIdle has a incorrect value of false and the socket is not destroyed when shutting down.
This implementation helped me to fix the problem:
server.on('request', function(req, res) {
var socket = req.socket;
socket._isIdle = false;
res.on('finish', function() {
socket._isIdle = true;
destroy(socket);
});
});
Do you have ideas why is this happening? It looks like req.socket references different objects, but it just makes no sense.
Hello!
I'm trying to use this module with Express, but I'm getting some weird behavior with this peace of code:
For some reason,
req.socket._isIdle = false;takes no effect, because when I examinereq.socket._isIdleinres.on('finish')function I can see it's still set totrue.But, the real problem happens here:
Because
socket._isIdlehas a incorrect value offalseand the socket is not destroyed when shutting down.This implementation helped me to fix the problem:
Do you have ideas why is this happening? It looks like
req.socketreferences different objects, but it just makes no sense.