fix(tempo): evict stale session channels#469
Draft
deodad wants to merge 1 commit into
Draft
Conversation
| function evictChannel(channelId: string): boolean { | ||
| const key = | ||
| channelIdToKey.get(channelId) ?? | ||
| Array.from(channelIdToKey).find( |
Collaborator
There was a problem hiding this comment.
can you add a comment here to what we are doing and why? this method is a little gnarly
| const chainId = challenge.request.methodDetails?.chainId ?? 0 | ||
| const client = await getClient({ chainId }) | ||
| const account = getAccount(client, context) | ||
| async createCredential({ challenge, context }) { |
Collaborator
There was a problem hiding this comment.
is this intentional?
| channelId: string | ||
| } | ||
|
|
||
| const ChannelNotFoundProblemType = 'https://paymentauth.org/problems/session/channel-not-found' |
Collaborator
There was a problem hiding this comment.
this can likely live alongside other errors / problem types -- we should centralize this since its part of the core control flow
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.
Summary
Evicts cached Tempo session channels after the server reports
session/channel-not-found.Motivation
Fixes #467. A session manager could keep signing vouchers against a channel after the service returned
410 Channel Not Found, leaving apps stuck until refresh.Changes
createSessionController()insrc/tempo/client/Session.tsso session cache state can sync from server responses.410https://paymentauth.org/problems/session/channel-not-foundresponse is observed.src/tempo/client/SessionManager.tsto delegate response sync to the session controller across fetch, open, voucher, and close paths.src/tempo/server/Session.test.tscovering eviction and reopen on the next request.Testing
./node_modules/.bin/tsgo -b src/tsconfig.json --pretty false./node_modules/.bin/vp test src/tempo/client/SessionManager.test.ts./node_modules/.bin/vp test src/tempo/server/Session.test.ts -t "evicts cached channel"./node_modules/.bin/vp fmt --check src/tempo/client/Session.ts src/tempo/client/SessionManager.ts src/tempo/server/Session.test.ts .changeset/fix-stale-session-channel.md./node_modules/.bin/vp lint src/tempo/client/Session.ts src/tempo/client/SessionManager.ts src/tempo/server/Session.test.ts