Suppress ETIMEDOUT errors

This commit is contained in:
Andris Reinman 2017-10-07 23:39:31 +03:00
parent 0fc0caa0f1
commit dc662520b2

View file

@ -190,8 +190,10 @@ class IMAPServer extends EventEmitter {
let remoteAddress = socket.remoteAddress;
let errorTimer = false;
let returned = false;
let onError = err => {
clearTimeout(errorTimer);
if (returned) {
return;
}
@ -223,7 +225,10 @@ class IMAPServer extends EventEmitter {
// upgrade connection
let tlsSocket = new tls.TLSSocket(socket, socketOptions);
tlsSocket.once('close', onError);
let onCloseError = () => {
errorTimer = setTimeout(onError, 150);
};
tlsSocket.once('close', onCloseError);
tlsSocket.once('error', onError);
tlsSocket.once('_tlsError', onError);
tlsSocket.once('clientError', onError);
@ -231,7 +236,7 @@ class IMAPServer extends EventEmitter {
tlsSocket.on('secure', () => {
socket.removeListener('error', onError);
tlsSocket.removeListener('close', onError);
tlsSocket.removeListener('close', onCloseError);
tlsSocket.removeListener('error', onError);
tlsSocket.removeListener('_tlsError', onError);
tlsSocket.removeListener('clientError', onError);