Skip to content

fix(tempo): evict stale session channels#469

Draft
deodad wants to merge 1 commit into
wevm:mainfrom
deodad:dad/fix-session-channel-not-found
Draft

fix(tempo): evict stale session channels#469
deodad wants to merge 1 commit into
wevm:mainfrom
deodad:dad/fix-session-channel-not-found

Conversation

@deodad
Copy link
Copy Markdown

@deodad deodad commented May 19, 2026

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

  • Added an internal createSessionController() in src/tempo/client/Session.ts so session cache state can sync from server responses.
  • Clear cached channel maps when a 410 https://paymentauth.org/problems/session/channel-not-found response is observed.
  • Updated src/tempo/client/SessionManager.ts to delegate response sync to the session controller across fetch, open, voucher, and close paths.
  • Added a regression test in src/tempo/server/Session.test.ts covering 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

function evictChannel(channelId: string): boolean {
const key =
channelIdToKey.get(channelId) ??
Array.from(channelIdToKey).find(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 }) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this intentional?

channelId: string
}

const ChannelNotFoundProblemType = 'https://paymentauth.org/problems/session/channel-not-found'
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can likely live alongside other errors / problem types -- we should centralize this since its part of the core control flow

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.

MPP sessions reuse stale channels after channel-not-found

2 participants