dgram: use addAbortListener

PR-URL: https://github.com/nodejs/node/pull/48550
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This commit is contained in:
atlowChemi 2023-07-06 02:00:57 +03:00 committed by Moshe Atlow
parent f6fc2dde95
commit bb031cbe2c
No known key found for this signature in database
GPG Key ID: CB1159A696865149

View File

@ -30,6 +30,7 @@ const {
ObjectDefineProperty,
ObjectSetPrototypeOf,
ReflectApply,
SymbolDispose,
} = primordials;
const errors = require('internal/errors');
@ -143,8 +144,8 @@ function Socket(type, listener) {
if (signal.aborted) {
onAborted();
} else {
signal.addEventListener('abort', onAborted);
this.once('close', () => signal.removeEventListener('abort', onAborted));
const disposable = EventEmitter.addAbortListener(signal, onAborted);
this.once('close', disposable[SymbolDispose]);
}
}
if (udpSocketChannel.hasSubscribers) {