Skip to content

fix: concurrent error settlement and iterator-protocol compliance - #400

Merged
ppeeou merged 2 commits into
mainfrom
fix/concurrent-error-settlement
Aug 8, 2026
Merged

ppeeou merged 2 commits into
mainfrom
fix/concurrent-error-settlement

Conversation

@ppeeou

@ppeeou ppeeou commented Aug 8, 2026

Copy link
Copy Markdown
Member

Summary

Fixes the two defects found while reviewing concurrent (follow-up to the concurrentPool review, separate PR as agreed). Regression tests were committed first and fail on the previous implementation.

  • Pending consumers hang after a source error: when the source throws inside a window, consumeBuffer rejected only the head waiter and break-ed, leaving any other pending next() promises unsettled forever (reproducible with three concurrent next() calls racing a 500ms timeout). Remaining waiters now resolve as done, matching concurrentPool's drain behavior.
  • AsyncIterator protocol violation: next() after the iterator finished returned a plain object instead of a Promise<IteratorResult>. Consumers calling .next().then(...) directly would crash; the as AsyncIterableIterator cast was hiding the type error. It now returns Promise.resolve(...).

The window-based evaluation semantics of concurrent are intentionally unchanged.

Test plan

  • 2 new regression tests, red before / green after
  • Full jest suite passes (140 suites, 1255 tests on this branch); lint 0; compile:check 0

🤖 Generated with Claude Code

ppeeou and others added 2 commits August 8, 2026 18:00
Two failing regressions:
- next() after the iterator is finished returns a plain object instead
  of a Promise, violating the AsyncIterator protocol
- when the source throws inside a window, only the head waiter is
  rejected and any other pending consumers are left unsettled forever

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…rotocol

- reject delivers the failure to the head waiter as before, and the
  remaining waiters now resolve as done instead of hanging forever
- next() after finished returns Promise.resolve(...) as the
  AsyncIterator protocol requires

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ppeeou ppeeou self-assigned this Aug 8, 2026
@ppeeou
ppeeou merged commit d6faed0 into main Aug 8, 2026
4 checks passed
@ppeeou
ppeeou deleted the fix/concurrent-error-settlement branch August 8, 2026 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant