You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Option to wait for all promises in Stream.prototype.forEach queue to finish before rejecting with a thrown error #67878
Preventing side effects from running after Stream.prototype.forEach has returned when concurrency is greater than 1 and a promise has rejected (which currently results in forEach immediately rejecting, leaving already started promises running).
In the following example up to 63 existing calls to processAsset may be running if one call throws an exception, resulting in observable side effects.
This is problematic when used in combination with import('node:fs/promises').mkdtempDisposable (disposal occurs while writes can still occur), or with tests where multiple tests cases reuse a common directly (or re-assign with a before callback).
What is the feature you are proposing to solve the problem?
A new option to wait for already started promises to be completed. If additional promise rejections or thrown errors occur, they are bundled up into a single AggregateError (so no error is silently discarded).
A potential further optimisation would be triggering the AbortSignal given to callees (wrapping one provided to forEach with AbortSignal.any()) and discarding expected errors (functions properly implementing the abortable API contract reject with the provided reason). However I consider this to be a separate nice-to-have request that deserves it's own separate option.
What alternatives have you considered?
Catching errors and triggering a provided AbortSignal, forEach will still return early.
Observing errors (catch and re-throw) and triggering a provided AbortSignal. Can reduce but not eliminate side effects.
Activity