Repository navigation
Conversation
After a rejected access token, session recovery stops the old Matrix client while its capabilities request is still in flight. In 42.2.0 the capabilities poller's error path re-arms a 30-35 s retry after stop(), so the stopped client polled /capabilities with the expired token for the rest of the page's life. 45.0.0 gives the poller a stopped state (matrix-org/matrix-js-sdk#5604). - matrix-js-sdk ^42.2.0 -> ^45.0.0 (lock 45.0.0) - matrix-widget-api 1.19.0 -> 1.20.0, the minimum 45 requires, so one copy is bundled - regression test drives the real session controller and SDK against a fetch double that holds responses in flight, then advances past the retry window RED on 42.2.0: all three cases fail on the expired-token capabilities assertion. GREEN on 45.0.0: 3/3 pass.
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
|
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.
Fixes #10538
Workspace spec:
workspace#095-matrix-sdk-45-upgrade— https://github.com/alkem-io/agents-hq/tree/095-matrix-sdk-45-upgrade/specs/095-matrix-sdk-45-upgrade/Root cause
When Synapse rejects an expired access token, matrix-js-sdk emits
Session.logged_outsynchronously and only then rethrows. The listener insrc/core/matrix/sessionController.tsrunsrecover(), which stops the old client at once. In 42.2.0,stopClient()only clears the capabilities poller's timers. The rejected (or still in flight) capabilities request then lands inCapabilityPoller.poll'scatch, which re-arms a 30–35 s retry. The stopped client therefore polled/capabilitieswith the expired token for the rest of the page's life. A request that succeeded after the stop re-armed the 6 h refresh in the same way.matrix-js-sdk 45.0.0 gives the poller a
stoppedstate (matrix-org/matrix-js-sdk#5604). Versions 42.3, 43 and 44 still have the race.Change
matrix-js-sdk^42.2.0→^45.0.0(the lockfile resolves 45.0.0).matrix-widget-api1.19.0→1.20.0. 45.0.0 requires^1.20.0, and this keeps a single copy in the bundle.New
src/core/matrix/sessionController.stoppedClient.test.tsdrives the real session controller with the real SDK. Itsfetchdouble holds responses in flight, so the order of events is controlled, and fake timers advance past the retry window. It has three cases:/syncgets the 401, and then it fails;Each case asserts that no request is started with the old token after recovery, and that the new client is the active one.
No product source change was needed.
RED/GREEN: on 42.2.0 all three cases fail on the expired-token capabilities assertion. On 45.0.0 all 3 pass.
Breaking-change audit (43 / 44 / 45)
Session.logged_outbefore rethrowing. The regression test exercises this path.getRoomSession, thesession_started/session_ended/memberships_changedevents,memberships, and membershipsender/deviceId/isExpired()/getMsUntilExpiry(). These were checked in the installed sources, becausematrixRtc.tsreaches them through local shapes that typecheck cannot see.member_id(widget-api 1.20)getRtcLivekitToken/delegateRtcLivekitDelayedLeavetake no parameters and still reject as unsupported. Typecheck passes.{ delay }only._unstable_updateDelayedEventstill sends the action in the body; that code is byte-identical to 42.2.0.vite.element-call.mjs)Out of scope
401 M_MISSING_TOKEN→200pair per call heartbeat. This is the SDK's own unauthenticated-first fallback; an optional follow-up.Verification
pnpm vitest run(658 files / 5712 tests),pnpm build,pnpm lint. Vitest ran underLC_ALL=en_US.UTF-8, because of the known bg_BG-localebudgetMetertest.capabilitiesrequests.