Skip to content

Commit

Permalink
stream: use internal addAbortListener
Browse files Browse the repository at this point in the history
PR-URL: #52081
Refs: #48596
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
atlowChemi authored and marco-ippolito committed May 3, 2024
1 parent 9f88736 commit 8442457
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/internal/streams/add-abort-signal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/internal/streams/end-of-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/streams/pipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/webstreams/readablestream.js
Original file line number Diff line number Diff line change
Expand Up @@ -1493,7 +1493,7 @@ function readableStreamPipeTo(
abortAlgorithm();
return promise.promise;
}
addAbortListener ??= require('events').addAbortListener;
addAbortListener ??= require('internal/events/abort_listener').addAbortListener;
disposable = addAbortListener(signal, abortAlgorithm);
}

Expand Down

0 comments on commit 8442457

Please sign in to comment.