GeezerVison is showing github.com — stream: cleanup promise uses in stream/iter · nodejs/node@dca736b
File treeExpand file treeCollapse file tree Open diff view settings lib/internal/streams/iter
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: lib/internal/streams/iter/broadcast.js +6-1Lines changed: 6 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -30,6 +30,8 @@ const { | 30 | 30 | abortSignal, | 31 | 31 | } = require('internal/abort_controller'); | 32 | 32 |
| | 33 | +const { markPromiseAsHandled } = internalBinding('util'); | | 34 | + | 33 | 35 | const { | 34 | 36 | codes: { | 35 | 37 | ERR_INVALID_ARG_TYPE, | @@ -989,7 +991,10 @@ const Broadcast = { | 989 | 991 | } | 990 | 992 | } | 991 | 993 | }; | 992 | | - PromisePrototypeThen(pump(), undefined, () => {}); | | 994 | + | | 995 | + const pumpPromise = PromisePrototypeThen( | | 996 | + pump(), undefined, undefined); | | 997 | + markPromiseAsHandled(pumpPromise); | 993 | 998 |
| 994 | 999 | return result; | 995 | 1000 | }, | |
Collapse file Copy file name to clipboardExpand all lines: lib/internal/streams/iter/pull.js +5-1Lines changed: 5 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -65,6 +65,8 @@ const { | 65 | 65 | kValidatedTransform, | 66 | 66 | } = require('internal/streams/iter/types'); | 67 | 67 |
| | 68 | +const { markPromiseAsHandled } = internalBinding('util'); | | 69 | + | 68 | 70 | // ============================================================================= | 69 | 71 | // Type Guards and Helpers | 70 | 72 | // ============================================================================= | @@ -905,7 +907,9 @@ function pullWithConsumerCleanup(source, transforms, signal) { | 905 | 907 | const close = sourceIterator[method] ?? sourceIterator.return; | 906 | 908 | if (typeof close === 'function') { | 907 | 909 | const result = FunctionPrototypeCall(close, sourceIterator, value); | 908 | | - PromisePrototypeThen(PromiseResolve(result), undefined, () => {}); | | 910 | + const cleanup = PromisePrototypeThen( | | 911 | + PromiseResolve(result), undefined, undefined); | | 912 | + markPromiseAsHandled(cleanup); | 909 | 913 | } | 910 | 914 | } | 911 | 915 |
| |
Collapse file Copy file name to clipboardExpand all lines: lib/internal/streams/iter/share.js +7-4Lines changed: 7 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -65,6 +65,8 @@ const { | 65 | 65 | validateInteger, | 66 | 66 | } = require('internal/validators'); | 67 | 67 |
| | 68 | +const { markPromiseAsHandled } = internalBinding('util'); | | 69 | + | 68 | 70 | // ============================================================================= | 69 | 71 | // Async Share Implementation | 70 | 72 | // ============================================================================= | @@ -240,8 +242,8 @@ class ShareImpl { | 240 | 242 | state.pendingNext, | 241 | 243 | getNext, | 242 | 244 | getNext); | 243 | | - state.pendingNext = | 244 | | - PromisePrototypeThen(next, undefined, () => {}); | | 245 | + state.pendingNext = next; | | 246 | + markPromiseAsHandled(state.pendingNext); | 245 | 247 | return next; | 246 | 248 | }, | 247 | 249 |
| @@ -284,11 +286,12 @@ class ShareImpl { | 284 | 286 | try { | 285 | 287 | const returnMethod = this.#sourceIterator?.return; | 286 | 288 | if (typeof returnMethod === 'function') { | 287 | | - PromisePrototypeThen( | | 289 | + const cleanup = PromisePrototypeThen( | 288 | 290 | PromiseResolve(FunctionPrototypeCall( | 289 | 291 | returnMethod, this.#sourceIterator)), | 290 | 292 | undefined, | 291 | | - () => {}); | | 293 | + undefined); | | 294 | + markPromiseAsHandled(cleanup); | 292 | 295 | } | 293 | 296 | } catch { | 294 | 297 | // Cancellation has precedence over source cleanup errors. | |
|