Repository navigation
fix(client): honor event cancellation after source completion - #65441
Conversation
There was a problem hiding this comment.
The fix works and I found no concerns that would block a merge. I ran the #65436 reproduction against the client source in each checkout. On the base, an aborted subscriber still got the buffered config.updated event after the shared source reached EOF. With this PR it returns { done: true }. The new tests fail on the base and pass here. The full packages/client suite passes, and so does tsc --noEmit.
Calling abort() after the source has finished is safe: finish({}) runs again just as it does from return(), empties the queue, and the second listener removal and subscriber delete do nothing. Subscribers that have not aborted still drain their buffered events, and then get done or the source error, as before.
Public API: unchanged. Only how a subscriber behaves after its signal aborts is different: it now ends with done, even if the source had already failed.
Related: #46393
Issue for this PR
Closes #65436
Related: #46393 established ordinary EOF buffering; this covers explicit subscriber cancellation afterward.
Type of change
What does this PR do?
Check the subscriber's
AbortSignalbefore reading queued events or completion state innext(). An aborted consumer now stops even if the shared source has already reached EOF or failed. Uncancelled consumers still drain buffered events at EOF and receive source errors after their buffered events. Regression tests cover both source endings on a shared connection.No feature flag is needed for this existing-behavior fix. No public API/schema changes or code generation required.
How did you verify your code works?
Verified on 2026-11-21 against
ba5bbef82c9fc27e033a12ca50657f4ec8d629daplus this fix:bun run check: exit 0, 35/35 tasks passed; 503 existing warnings, zero errors.packages/client,bun run typecheck:tsc: exit 0;bun run test test/shared-events.test.ts test/promise.test.ts: 59 passed, zero failed across the shared-events and public Promise suites.Screenshots / recordings
Not applicable (client event-iterator change).
Checklist
Added by the opencode bot (AI-generated).
Related: #46393