Skip to content

fix(client): honor event cancellation after source completion - #65441

Merged
neriousy merged 1 commit into
anomalyco:devfrom
chirag127:event-abort-eof
Nov 23, 2026
Merged

neriousy merged 1 commit into
anomalyco:devfrom
chirag127:event-abort-eof

Conversation

@chirag127

@chirag127 chirag127 commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #65436

Related: #46393 established ordinary EOF buffering; this covers explicit subscriber cancellation afterward.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Check the subscriber's AbortSignal before reading queued events or completion state in next(). 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 ba5bbef82c9fc27e033a12ca50657f4ec8d629da plus this fix:

  • Both new regression cases failed on the baseline and passed with the fix.
  • Native Linux root bun run check: exit 0, 35/35 tasks passed; 503 existing warnings, zero errors.
  • From 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.
  • Windows shared-events test repeats: 180 passes total.

Screenshots / recordings

Not applicable (client event-iterator change).

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Added by the opencode bot (AI-generated).

Related: #46393

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@neriousy
neriousy merged commit b8cbd0e into anomalyco:dev Nov 23, 2026
13 checks passed
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.

client: aborted event subscription yields buffered events after EOF

2 participants