Skip to content

fix(handlers): abort in-flight subscription stream on client disconnect - #715

Open
Priyanshubhartistm wants to merge 1 commit into
cameri:mainfrom
Priyanshubhartistm:fix/subscribe-abort-controller
Open

fix(handlers): abort in-flight subscription stream on client disconnect#715
Priyanshubhartistm wants to merge 1 commit into
cameri:mainfrom
Priyanshubhartistm:fix/subscribe-abort-controller

Conversation

@Priyanshubhartistm

Copy link
Copy Markdown
Collaborator

Description

SubscribeMessageHandler implements IAbortable, but its abort() method was a no-op the entire AbortController (field, constructor init, abort() body, and the addAbortSignal wrapping around the DB event stream) was commented out. This PR restores that wiring so calling abort() actually cancels the in-flight streaming query via AbortController.signal.

Related Issue

Fixes #709

Motivation and Context

When a client disconnects mid-subscription while a large historical-event query is streaming, the query previously continued running to completion in the background, holding a DB connection open and wasting CPU/memory. web-socket-adapter.ts already calls handler.abort() on client close for any handler implementing IAbortable, but because the controller was disabled, that call did nothing.

How Has This Been Tested?

  • Added a unit test (test/unit/handlers/subscribe-message-handler.spec.ts) asserting that calling handler.abort() while fetchAndSend is in-flight destroys the underlying event stream.
  • Ran the full unit suite (pnpm run test:unit, 1394 passing) and CLI suite (pnpm run test:cli, 73 passing).
  • Ran unit coverage (pnpm run cover:unit) — subscribe-message-handler.ts at 100% statement/line coverage.
  • Ran the full Docker integration suite (pnpm run docker:test:integration) — 99 scenarios / 489 steps, all passing, confirming no regression to existing subscription behavior.
  • Ran lint, format check, dep check, and build checks — all clean (pre-existing unrelated format issues on main are untouched by this change).

Screenshots (if appropriate):

N/A — backend-only change, no UI impact.

Types of changes

  • Non-functional change (docs, style, minor refactor)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my code changes.
  • I added a changeset, or this is docs-only and I added an empty changeset.
  • All new and existing tests passed.

Signed-off-by: Priyanshubhartistm <bhartipriyanshustm@gmail.com>
@coveralls

Copy link
Copy Markdown
Collaborator

Coverage Status

Coverage is 69.77%Priyanshubhartistm:fix/subscribe-abort-controller into cameri:main. No base build found for cameri:main.

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.

[BUG] Subscription streaming abort is completely disabled - in-flight queries cannot be cancelled

2 participants