fix(async): pooledMap surfaces errors thrown by the input iterable#7169
Open
LeSingh1 wants to merge 2 commits into
Open
fix(async): pooledMap surfaces errors thrown by the input iterable#7169LeSingh1 wants to merge 2 commits into
LeSingh1 wants to merge 2 commits into
Conversation
The catch block in pooledMap's writer loop discarded the error that came out of `for await (const item of array)` and built an AggregateError populated solely from the executing transformations. When the iterable itself threw (and no transformation had rejected), that meant an empty `AggregateError.errors` — callers saw only the generic "Cannot complete the mapping" message with no way to recover the underlying cause (denoland#6716). Bind the caught value as `iterError` and include it in `errors` if it isn't already there. Promise.race rejections from the executing pool are already surfaced via the existing allSettled walk, so the `includes` check prevents duplicates for the common transformation- rejection path. Adds a regression test covering the iterable-throws case and verifies the existing 'handles errors' test still produces exactly the expected pair of rejections. Fixes denoland#6716
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7169 +/- ##
=======================================
Coverage 94.57% 94.57%
=======================================
Files 636 636
Lines 52142 52143 +1
Branches 9401 9402 +1
=======================================
+ Hits 49315 49316 +1
Misses 2249 2249
Partials 578 578 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #6716.
When an async iterable passed to
pooledMapthrows (rather than a transformation), the catch block discarded the error and built anAggregateErrorpopulated solely from the executing transformations. With no transformation rejections in flight, callers saw only:The underlying cause was unrecoverable.
Repro from the issue:
After the patch the iterable's error rides through in
AggregateError.errors:Implementation: bind the catch's value as
iterErroranderrors.push(iterError)only when it isn't already inerrors. ThePromise.racerejections from the executing pool are already surfaced via the existingallSettledwalk, so theincludescheck prevents the common transformation-rejection path from duplicating its own reason.Tests:
pooledMap() surfaces errors thrown by the input iterable (#6716)pins the iterable-throws case.pooledMap() handles errorstest (which exercisesPromise.racerejections, not iterable throws) still produces exactly two rejections, confirming no double-counting.All 6
pool_test.tstests pass.