fix(handlers): abort in-flight subscription stream on client disconnect - #715
Open
Priyanshubhartistm wants to merge 1 commit into
Open
fix(handlers): abort in-flight subscription stream on client disconnect#715Priyanshubhartistm wants to merge 1 commit into
Priyanshubhartistm wants to merge 1 commit into
Conversation
Signed-off-by: Priyanshubhartistm <bhartipriyanshustm@gmail.com>
Collaborator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
SubscribeMessageHandlerimplementsIAbortable, but itsabort()method was a no-op the entireAbortController(field, constructor init,abort()body, and theaddAbortSignalwrapping around the DB event stream) was commented out. This PR restores that wiring so callingabort()actually cancels the in-flight streaming query viaAbortController.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.tsalready callshandler.abort()on client close for any handler implementingIAbortable, but because the controller was disabled, that call did nothing.How Has This Been Tested?
test/unit/handlers/subscribe-message-handler.spec.ts) asserting that callinghandler.abort()whilefetchAndSendis in-flight destroys the underlying event stream.pnpm run test:unit, 1394 passing) and CLI suite (pnpm run test:cli, 73 passing).pnpm run cover:unit) —subscribe-message-handler.tsat 100% statement/line coverage.pnpm run docker:test:integration) — 99 scenarios / 489 steps, all passing, confirming no regression to existing subscription behavior.mainare untouched by this change).Screenshots (if appropriate):
N/A — backend-only change, no UI impact.
Types of changes
Checklist: