feat: add async event iterators#1977
Conversation
Resolves #879
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fd75792ee1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Comprehensive review completed against e7cd5be. Original issue reproduced on base 95b54e5: a minimal EventStream async imageFileDone listener received two events while the first handler was blocked, producing start:first, start:second, end:second. This confirms #879: synchronous callbacks do not serialize awaited work. The reproduction passed with node_modules/.bin/jest tests/lib/EventStream.issue879-repro.test.ts --runInBand (1/1). Validation:
Compatibility:
No blocking or nonblocking findings. Approved. |
jbeckwith-oai
left a comment
There was a problem hiding this comment.
Approved after reproducing issue #879 on base 95b54e5 and validating e7cd5be with 10 targeted tests plus scoped type, lint, formatting, CI, compatibility, and edge-case review. No blocking or nonblocking findings. Full evidence: #1977 (comment)
Summary
events(eventName)async iterator toEventStreamimageFileDoneassistant helper eventsWhy
Issue #879 needs async/await control for SDK convenience events such as
imageFileDone. Existing.on()callbacks are synchronous, so callers cannot naturally process each repeated event sequentially.Behavior
stream.events(eventName)yields the emitted argument tuple for every occurrence. It queues events while the consumer awaits work, ends with the stream, and surfaces stream errors or aborts after previously queued events have been drained. Existing.on()behavior is unchanged.Validation
pnpm exec jest tests/lib/EventStream.test.ts --runInBandpnpm exec tsc --noEmitpnpm run lintResolves #879