node_modules: update (#297)

Co-authored-by: dawidd6 <9713907+dawidd6@users.noreply.github.com>
This commit is contained in:
Dawid Dziurla
2026-06-15 07:32:52 +02:00
committed by GitHub
parent d86d472c50
commit 1369c5b90d
27 changed files with 662 additions and 159 deletions
+40 -9
View File
@@ -51,9 +51,9 @@ function decodeServerResponse(str) {
* * **requireTLS** - forces the client to use STARTTLS
* * **name** - the name of the client server
* * **localAddress** - outbound address to bind to (see: http://nodejs.org/api/net.html#net_net_connect_options_connectionlistener)
* * **greetingTimeout** - Time to wait in ms until greeting message is received from the server (defaults to 10000)
* * **connectionTimeout** - how many milliseconds to wait for the connection to establish
* * **socketTimeout** - Time of inactivity until the connection is closed (defaults to 1 hour)
* * **greetingTimeout** - Time to wait in ms until greeting message is received from the server (defaults to 30 seconds)
* * **connectionTimeout** - how many milliseconds to wait for the connection to establish (defaults to 2 minutes)
* * **socketTimeout** - Time of inactivity until the connection is closed (defaults to 10 minutes)
* * **dnsTimeout** - Time to wait in ms for the DNS requests to be resolved (defaults to 30 seconds)
* * **lmtp** - if true, uses LMTP instead of SMTP protocol
* * **logger** - bunyan compatible logger interface
@@ -211,6 +211,13 @@ class SMTPConnection extends EventEmitter {
*/
this._closing = false;
/**
* Message DATA stream currently piped to the socket, if any. Tracked so
* close() can unpipe it before tearing the socket down.
* @private
*/
this._currentDataStream = false;
/**
* Callbacks for socket's listeners
*/
@@ -470,6 +477,17 @@ class SMTPConnection extends EventEmitter {
const socket = (this._socket && this._socket.socket) || this._socket;
// Detach any in-flight DATA stream from the socket so the source stream
// can be garbage-collected once the socket is gone.
if (this._currentDataStream) {
try {
this._currentDataStream.unpipe(this._socket);
} catch (_E) {
// ignore
}
this._currentDataStream = false;
}
if (socket && !socket.destroyed) {
try {
// Clear socket timeout to prevent timer leaks
@@ -820,7 +838,7 @@ class SMTPConnection extends EventEmitter {
return;
}
let data = (chunk || '').toString('binary');
let data = chunk.toString('binary');
let lines = (this._remainder + data).split(/\r?\n/);
let lastline;
@@ -953,7 +971,9 @@ class SMTPConnection extends EventEmitter {
*/
_onEnd() {
if (this._socket && !this._socket.destroyed) {
this._socket.destroy();
// Peer sent FIN — finish our half of the close gracefully rather
// than destroying. 'close' fires after the OS finalizes teardown.
this._socket.end();
}
}
@@ -1005,6 +1025,15 @@ class SMTPConnection extends EventEmitter {
opts.servername = this.servername;
}
// Remove all listeners from the plain socket to allow proper garbage
// collection. Used on both the TLS-success path and the synchronous
// tls.connect() throw path; either way the plain socket is done.
const removePlainSocketListeners = () => {
socketPlain.removeListener('close', this._onSocketClose);
socketPlain.removeListener('end', this._onSocketEnd);
socketPlain.removeListener('error', this._onSocketError);
};
this.upgrading = true;
// tls.connect is not an asynchronous function however it may still throw errors and requires to be wrapped with try/catch
try {
@@ -1013,14 +1042,12 @@ class SMTPConnection extends EventEmitter {
this.upgrading = false;
this._socket.on('data', this._onSocketData);
// Remove all listeners from the plain socket to allow proper garbage collection
socketPlain.removeListener('close', this._onSocketClose);
socketPlain.removeListener('end', this._onSocketEnd);
socketPlain.removeListener('error', this._onSocketError);
removePlainSocketListeners();
return callback(null, true);
});
} catch (err) {
removePlainSocketListeners();
return callback(err);
}
@@ -1297,6 +1324,7 @@ class SMTPConnection extends EventEmitter {
});
}
this._currentDataStream = dataStream;
dataStream.pipe(this._socket, {
end: false
});
@@ -1318,6 +1346,9 @@ class SMTPConnection extends EventEmitter {
}
dataStream.once('end', () => {
if (this._currentDataStream === dataStream) {
this._currentDataStream = false;
}
this.logger.info(
{
tnx: 'message',