From a9528e87b9362a66124b79a7b9057904a134fef7 Mon Sep 17 00:00:00 2001 From: atlowChemi Date: Thu, 14 Mar 2024 10:56:35 +0200 Subject: [PATCH] stream: use internal addAbortListener PR-URL: https://github.com/nodejs/node/pull/52081 Refs: https://github.com/nodejs/node/pull/48596 Reviewed-By: Moshe Atlow Reviewed-By: Benjamin Gruenbaum Reviewed-By: Antoine du Hamel Reviewed-By: Luigi Pinca --- lib/internal/streams/add-abort-signal.js | 2 +- lib/internal/streams/end-of-stream.js | 4 ++-- lib/internal/streams/pipeline.js | 2 +- lib/internal/webstreams/readablestream.js | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/internal/streams/add-abort-signal.js b/lib/internal/streams/add-abort-signal.js index 819be3ff63e915..10e5545a28345b 100644 --- a/lib/internal/streams/add-abort-signal.js +++ b/lib/internal/streams/add-abort-signal.js @@ -51,7 +51,7 @@ module.exports.addAbortSignalNoValidate = function(signal, stream) { if (signal.aborted) { onAbort(); } else { - addAbortListener ??= require('events').addAbortListener; + addAbortListener ??= require('internal/events/abort_listener').addAbortListener; const disposable = addAbortListener(signal, onAbort); eos(stream, disposable[SymbolDispose]); } diff --git a/lib/internal/streams/end-of-stream.js b/lib/internal/streams/end-of-stream.js index 663222e3149bad..eda08b5fc60b93 100644 --- a/lib/internal/streams/end-of-stream.js +++ b/lib/internal/streams/end-of-stream.js @@ -254,7 +254,7 @@ function eos(stream, options, callback) { if (options.signal.aborted) { process.nextTick(abort); } else { - addAbortListener ??= require('events').addAbortListener; + addAbortListener ??= require('internal/events/abort_listener').addAbortListener; const disposable = addAbortListener(options.signal, abort); const originalCallback = callback; callback = once((...args) => { @@ -278,7 +278,7 @@ function eosWeb(stream, options, callback) { if (options.signal.aborted) { process.nextTick(abort); } else { - addAbortListener ??= require('events').addAbortListener; + addAbortListener ??= require('internal/events/abort_listener').addAbortListener; const disposable = addAbortListener(options.signal, abort); const originalCallback = callback; callback = once((...args) => { diff --git a/lib/internal/streams/pipeline.js b/lib/internal/streams/pipeline.js index aac7f65f0404d8..4cf6b02766b6a8 100644 --- a/lib/internal/streams/pipeline.js +++ b/lib/internal/streams/pipeline.js @@ -208,7 +208,7 @@ function pipelineImpl(streams, callback, opts) { finishImpl(new AbortError()); } - addAbortListener ??= require('events').addAbortListener; + addAbortListener ??= require('internal/events/abort_listener').addAbortListener; let disposable; if (outerSignal) { disposable = addAbortListener(outerSignal, abort); diff --git a/lib/internal/webstreams/readablestream.js b/lib/internal/webstreams/readablestream.js index d4526011bec46d..f30788421f2cc4 100644 --- a/lib/internal/webstreams/readablestream.js +++ b/lib/internal/webstreams/readablestream.js @@ -1523,7 +1523,7 @@ function readableStreamPipeTo( abortAlgorithm(); return promise.promise; } - addAbortListener ??= require('events').addAbortListener; + addAbortListener ??= require('internal/events/abort_listener').addAbortListener; disposable = addAbortListener(signal, abortAlgorithm); }