Commit bf4bd4416f3 for nodejs
commit bf4bd4416f3a7d0ede1db49f20f1091b6dba3ecc
Author: James M Snell <jasnell@gmail.com>
Date: Sun Aug 30 19:03:18 2026 +0000
stream: cleanup promise uses in stream/iter
Signed-off-by: James M Snell <jasnell@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66079
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
diff --git a/lib/internal/streams/iter/broadcast.js b/lib/internal/streams/iter/broadcast.js
index 3b37a5b5f2a..5d85af8b7da 100644
--- a/lib/internal/streams/iter/broadcast.js
+++ b/lib/internal/streams/iter/broadcast.js
@@ -30,6 +30,8 @@ const {
abortSignal,
} = require('internal/abort_controller');
+const { markPromiseAsHandled } = internalBinding('util');
+
const {
codes: {
ERR_INVALID_ARG_TYPE,
@@ -989,7 +991,10 @@ const Broadcast = {
}
}
};
- PromisePrototypeThen(pump(), undefined, () => {});
+
+ const pumpPromise = PromisePrototypeThen(
+ pump(), undefined, undefined);
+ markPromiseAsHandled(pumpPromise);
return result;
},
diff --git a/lib/internal/streams/iter/pull.js b/lib/internal/streams/iter/pull.js
index 9b4d7fb884d..70354edb10b 100644
--- a/lib/internal/streams/iter/pull.js
+++ b/lib/internal/streams/iter/pull.js
@@ -65,6 +65,8 @@ const {
kValidatedTransform,
} = require('internal/streams/iter/types');
+const { markPromiseAsHandled } = internalBinding('util');
+
// =============================================================================
// Type Guards and Helpers
// =============================================================================
@@ -905,7 +907,9 @@ function pullWithConsumerCleanup(source, transforms, signal) {
const close = sourceIterator[method] ?? sourceIterator.return;
if (typeof close === 'function') {
const result = FunctionPrototypeCall(close, sourceIterator, value);
- PromisePrototypeThen(PromiseResolve(result), undefined, () => {});
+ const cleanup = PromisePrototypeThen(
+ PromiseResolve(result), undefined, undefined);
+ markPromiseAsHandled(cleanup);
}
}
diff --git a/lib/internal/streams/iter/share.js b/lib/internal/streams/iter/share.js
index 89170bdabd2..57e449f9e1c 100644
--- a/lib/internal/streams/iter/share.js
+++ b/lib/internal/streams/iter/share.js
@@ -65,6 +65,8 @@ const {
validateInteger,
} = require('internal/validators');
+const { markPromiseAsHandled } = internalBinding('util');
+
// =============================================================================
// Async Share Implementation
// =============================================================================
@@ -240,8 +242,8 @@ class ShareImpl {
state.pendingNext,
getNext,
getNext);
- state.pendingNext =
- PromisePrototypeThen(next, undefined, () => {});
+ state.pendingNext = next;
+ markPromiseAsHandled(state.pendingNext);
return next;
},
@@ -284,11 +286,12 @@ class ShareImpl {
try {
const returnMethod = this.#sourceIterator?.return;
if (typeof returnMethod === 'function') {
- PromisePrototypeThen(
+ const cleanup = PromisePrototypeThen(
PromiseResolve(FunctionPrototypeCall(
returnMethod, this.#sourceIterator)),
undefined,
- () => {});
+ undefined);
+ markPromiseAsHandled(cleanup);
}
} catch {
// Cancellation has precedence over source cleanup errors.