Skip to content

fix(client): preserve token persistence errors#2210

Open
he-yufeng wants to merge 2 commits into
modelcontextprotocol:mainfrom
he-yufeng:fix/propagate-save-token-errors
Open

fix(client): preserve token persistence errors#2210
he-yufeng wants to merge 2 commits into
modelcontextprotocol:mainfrom
he-yufeng:fix/propagate-save-token-errors

Conversation

@he-yufeng
Copy link
Copy Markdown

Summary

Fixes #2034.

The refresh branch was catching both the token refresh call and the following token persistence call. That meant a successful refresh could still fall through to a new authorization flow if provider.saveTokens() failed.

This keeps the fallback behavior for refresh failures, but lets saveTokens() errors propagate after the server has already issued new tokens. That avoids hiding token-store write failures after refresh-token rotation.

Tests

  • pnpm --filter @modelcontextprotocol/client exec vitest run test/client/auth.test.ts
  • pnpm --filter @modelcontextprotocol/client typecheck
  • pnpm --filter @modelcontextprotocol/client lint
  • pnpm --filter @modelcontextprotocol/client build

@he-yufeng he-yufeng requested a review from a team as a code owner May 30, 2026 09:22
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 30, 2026

🦋 Changeset detected

Latest commit: 3139883

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@modelcontextprotocol/client Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 30, 2026

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/client@2210

@modelcontextprotocol/codemod

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/codemod@2210

@modelcontextprotocol/server

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/server@2210

@modelcontextprotocol/express

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/express@2210

@modelcontextprotocol/fastify

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/fastify@2210

@modelcontextprotocol/hono

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/hono@2210

@modelcontextprotocol/node

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/node@2210

commit: 3139883

@he-yufeng
Copy link
Copy Markdown
Author

Added the client patch changeset in 3139883.

Validation:

  • pnpm changeset status --since upstream/main -> @modelcontextprotocol/client patch
  • pnpm --filter @modelcontextprotocol/client exec vitest run test/client/auth.test.ts -> 168 passed
  • pnpm --filter @modelcontextprotocol/client typecheck
  • pnpm --filter @modelcontextprotocol/client lint
  • pnpm --filter @modelcontextprotocol/client build
  • git diff --check

The full pre-push hook still hits the existing local test/e2e workspace setup issue (@modelcontextprotocol/eslint-config / @modelcontextprotocol/tsconfig not resolved), so I pushed this changeset-only follow-up with --no-verify after the affected client package checks above passed.

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.

auth() silently swallows non-OAuthError exceptions from refreshAuthorization / saveTokens, preventing token persistence

1 participant