Skip to content

Commit 002ce31

Browse files
atlowChemijuanarbol
authored andcommitted
dgram: use addAbortListener
PR-URL: #48550 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent 5a382d0 commit 002ce31

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/dgram.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const {
3030
ObjectDefineProperty,
3131
ObjectSetPrototypeOf,
3232
ReflectApply,
33+
SymbolDispose,
3334
} = primordials;
3435

3536
const errors = require('internal/errors');
@@ -143,8 +144,8 @@ function Socket(type, listener) {
143144
if (signal.aborted) {
144145
onAborted();
145146
} else {
146-
signal.addEventListener('abort', onAborted);
147-
this.once('close', () => signal.removeEventListener('abort', onAborted));
147+
const disposable = EventEmitter.addAbortListener(signal, onAborted);
148+
this.once('close', disposable[SymbolDispose]);
148149
}
149150
}
150151
if (udpSocketChannel.hasSubscribers) {

0 commit comments

Comments
 (0)