GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — stream: cleanup promise uses in stream/iter · nodejs/node@dca736b

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal/streams/iter
    • broadcast.js
    • pull.js
    • share.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/streams/iter/broadcast.js‎

Copy file name to clipboardExpand all lines: lib/internal/streams/iter/broadcast.js
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ const {
3030
abortSignal,
3131
} = require('internal/abort_controller');
3232

33+
const { markPromiseAsHandled } = internalBinding('util');
34+
3335
const {
3436
codes: {
3537
ERR_INVALID_ARG_TYPE,
@@ -989,7 +991,10 @@ const Broadcast = {
989991
}
990992
}
991993
};
992-
PromisePrototypeThen(pump(), undefined, () => {});
994+
995+
const pumpPromise = PromisePrototypeThen(
996+
pump(), undefined, undefined);
997+
markPromiseAsHandled(pumpPromise);
993998

994999
return result;
9951000
},
Collapse file

‎lib/internal/streams/iter/pull.js‎

Copy file name to clipboardExpand all lines: lib/internal/streams/iter/pull.js
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ const {
6565
kValidatedTransform,
6666
} = require('internal/streams/iter/types');
6767

68+
const { markPromiseAsHandled } = internalBinding('util');
69+
6870
// =============================================================================
6971
// Type Guards and Helpers
7072
// =============================================================================
@@ -905,7 +907,9 @@ function pullWithConsumerCleanup(source, transforms, signal) {
905907
const close = sourceIterator[method] ?? sourceIterator.return;
906908
if (typeof close === 'function') {
907909
const result = FunctionPrototypeCall(close, sourceIterator, value);
908-
PromisePrototypeThen(PromiseResolve(result), undefined, () => {});
910+
const cleanup = PromisePrototypeThen(
911+
PromiseResolve(result), undefined, undefined);
912+
markPromiseAsHandled(cleanup);
909913
}
910914
}
911915

Collapse file

‎lib/internal/streams/iter/share.js‎

Copy file name to clipboardExpand all lines: lib/internal/streams/iter/share.js
+7-4Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ const {
6565
validateInteger,
6666
} = require('internal/validators');
6767

68+
const { markPromiseAsHandled } = internalBinding('util');
69+
6870
// =============================================================================
6971
// Async Share Implementation
7072
// =============================================================================
@@ -240,8 +242,8 @@ class ShareImpl {
240242
state.pendingNext,
241243
getNext,
242244
getNext);
243-
state.pendingNext =
244-
PromisePrototypeThen(next, undefined, () => {});
245+
state.pendingNext = next;
246+
markPromiseAsHandled(state.pendingNext);
245247
return next;
246248
},
247249

@@ -284,11 +286,12 @@ class ShareImpl {
284286
try {
285287
const returnMethod = this.#sourceIterator?.return;
286288
if (typeof returnMethod === 'function') {
287-
PromisePrototypeThen(
289+
const cleanup = PromisePrototypeThen(
288290
PromiseResolve(FunctionPrototypeCall(
289291
returnMethod, this.#sourceIterator)),
290292
undefined,
291-
() => {});
293+
undefined);
294+
markPromiseAsHandled(cleanup);
292295
}
293296
} catch {
294297
// Cancellation has precedence over source cleanup errors.

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.