We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 002ce31 commit ac11264Copy full SHA for ac11264
1 file changed
lib/net.js
@@ -35,6 +35,7 @@ const {
35
ObjectDefineProperty,
36
ObjectSetPrototypeOf,
37
Symbol,
38
+ SymbolDispose,
39
} = primordials;
40
41
const EventEmitter = require('events');
@@ -1605,17 +1606,18 @@ function afterConnect(status, handle, req, readable, writable) {
1605
1606
function addClientAbortSignalOption(self, options) {
1607
validateAbortSignal(options.signal, 'options.signal');
1608
const { signal } = options;
1609
+ let disposable;
1610
1611
function onAbort() {
- signal.removeEventListener('abort', onAbort);
1612
+ disposable?.[SymbolDispose]();
1613
self._aborted = true;
1614
}
1615
1616
if (signal.aborted) {
1617
process.nextTick(onAbort);
1618
} else {
1619
process.nextTick(() => {
- signal.addEventListener('abort', onAbort);
1620
+ disposable = EventEmitter.addAbortListener(signal, onAbort);
1621
});
1622
1623
@@ -1695,8 +1697,8 @@ function addServerAbortSignalOption(self, options) {
1695
1697
1696
1698
process.nextTick(onAborted);
1699
- signal.addEventListener('abort', onAborted);
- self.once('close', () => signal.removeEventListener('abort', onAborted));
1700
+ const disposable = EventEmitter.addAbortListener(signal, onAborted);
1701
+ self.once('close', disposable[SymbolDispose]);
1702
1703
1704
0 commit comments