diff --git a/lib/net.js b/lib/net.js index de2cd517eb4580..c72beaaef34f65 100644 --- a/lib/net.js +++ b/lib/net.js @@ -41,6 +41,7 @@ const { } = primordials; const EventEmitter = require('events'); +const { addAbortListener } = require('internal/events/abort_listener'); const stream = require('stream'); let debug = require('internal/util/debuglog').debuglog('net', (fn) => { debug = fn; @@ -1631,7 +1632,7 @@ function addClientAbortSignalOption(self, options) { process.nextTick(onAbort); } else { process.nextTick(() => { - disposable = EventEmitter.addAbortListener(signal, onAbort); + disposable = addAbortListener(signal, onAbort); }); } } @@ -1723,7 +1724,7 @@ function addServerAbortSignalOption(self, options) { if (signal.aborted) { process.nextTick(onAborted); } else { - const disposable = EventEmitter.addAbortListener(signal, onAborted); + const disposable = addAbortListener(signal, onAborted); self.once('close', disposable[SymbolDispose]); } }