Skip to content

fix(async/unstable): harden pooledMapSettled error handling and abort#7093

Open
tomas-zijdemans wants to merge 1 commit intodenoland:mainfrom
tomas-zijdemans:poolSettled-next
Open

fix(async/unstable): harden pooledMapSettled error handling and abort#7093
tomas-zijdemans wants to merge 1 commit intodenoland:mainfrom
tomas-zijdemans:poolSettled-next

Conversation

@tomas-zijdemans
Copy link
Copy Markdown
Contributor

Harden pooledMapSettled() error handling, abort responsiveness, and resource cleanup.

Bug Fixes

  • Source iterable errors now propagate. Previously silently swallowed; now the iterator rejects with the original error after yielding all in-flight settled results.
  • Abort signal interrupts slow/stalled async sources. Each it.next() is raced against the signal, so cancellation is immediate instead of waiting for the source to resume.
  • Deterministic error priority. Abort reason wins when signal is already aborted at source failure; source error wins otherwise.

Performance

  • executing now uses Set instead of Array. This eliminates O(n) indexOf/splice on every task completion.
  • Single abort listener per call instead of creating/tearing down one per raceWithSignal() invocation.

Resource Cleanup

  • Fallback generator path now cancels the reader and releases the lock in finally on early consumer break.
  • it.return() called on abort so source iterables can run cleanup.
  • .catch(() => {}) guards on fire-and-forget promises prevent unhandled-rejection noise.

Docs & Tests

  • Updated @throws JSDoc to document both rejection modes.
  • Added 9 test cases covering: source error propagation, error-vs-abort priority, abort interrupting slow/stalled sources, and early consumer break (including fallback path).

@github-actions github-actions bot added the async label Apr 12, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.43%. Comparing base (a3a6ef6) to head (7f4db0b).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7093   +/-   ##
=======================================
  Coverage   94.43%   94.43%           
=======================================
  Files         630      630           
  Lines       50566    50602   +36     
  Branches     8969     8988   +19     
=======================================
+ Hits        47750    47786   +36     
  Misses       2247     2247           
  Partials      569      569           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant