fix(core): clear recently-cancelled request ids on connection close#892
Open
devcrocod wants to merge 1 commit into
Open
fix(core): clear recently-cancelled request ids on connection close#892devcrocod wants to merge 1 commit into
devcrocod wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the core Protocol connection teardown path to fully reset Protocol-scoped per-request bookkeeping by clearing the buffer of recently-cancelled outbound request IDs during doClose. This aligns recentlyCancelledRequestIds cleanup with the existing teardown behavior for response handlers, progress handlers, and in-flight request jobs.
Changes:
- Clear
recentlyCancelledRequestIdsduringProtocol.doClose(...)to avoid carrying buffered cancellations across a close/reconnect. - Keep teardown symmetry with other Protocol-scoped request tracking structures (
_responseHandlers,_progressHandlers,inFlightRequestJobs).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Clear the recently-cancelled request id buffer in
doCloseso connection teardown fully resets per-request bookkeeping.Motivation and Context
Follow-up to #884.
doClosealready resets_responseHandlers,_progressHandlers, andinFlightRequestJobs, but leftrecentlyCancelledRequestIdspopulated across a close. This aligns teardown to clear all Protocol-scoped per-request state.Not a correctness bug: the buffer is bounded (256) and self-evicting, request ids are random UUIDs so stale entries cannot false-match a new connection, and the post-close
onMessageguard drops late messages from the old transport before the buffer is consulted. The change removes the lone asymmetry indoClose.How Has This Been Tested?
./gradlew :kotlin-sdk-core:compileKotlinJvm./gradlew :kotlin-sdk-core:jvmTest --tests "*ProtocolTest*"Breaking Changes
None.
Types of changes
Checklist
Additional context
recentlyCancelledRequestIdsis Protocol-scoped (like_responseHandlers/_progressHandlers), so it is reset indoCloserather than on the per-connectionConnectionobject.