MCPcopy Index your code
hub / github.com/nodejs/node / cleanupIterators

Function cleanupIterators

lib/internal/streams/iter/consumers.js:516–542  ·  view source on GitHub ↗
(iterators, primaryError)

Source from the content-addressed store, hash-verified

514}
515
516async function cleanupIterators(iterators, primaryError) {
517 let cleanupError;
518 await SafePromiseAllReturnVoid(iterators, async (iterator) => {
519 if (iterator.return) {
520 try {
521 await iterator.return();
522 } catch (err) {
523 // Keep the first cleanup error encountered.
524 cleanupError ??= err;
525 }
526 }
527 });
528 if (cleanupError !== undefined) {
529 if (primaryError !== undefined) {
530 // Both a primary error and a cleanup error occurred.
531 // Wrap in SuppressedError so neither is lost:
532 // .error = primaryError, .suppressed = cleanupError.
533 // eslint-disable-next-line no-restricted-syntax
534 throw new SuppressedError(primaryError, cleanupError);
535 }
536 // No primary error - the cleanup error is the only error.
537 throw cleanupError;
538 }
539 if (primaryError !== undefined) {
540 throw primaryError;
541 }
542}
543
544module.exports = {
545 array,

Callers 1

[SymbolAsyncIterator]Function · 0.85

Calls 1

returnMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…