fix(client): surface OAuth token persistence failures#2121
Conversation
|
@modelcontextprotocol/client
@modelcontextprotocol/server
@modelcontextprotocol/express
@modelcontextprotocol/fastify
@modelcontextprotocol/hono
@modelcontextprotocol/node
commit: |
|
The red CI job is the existing Cloudflare Workers/Miniflare flaky path ( est/server/cloudflareWorkers.test.ts: Network connection lost). The OAuth test, full client auth test file, typecheck, lint, and pre-push workspace checks pass locally. I don't have repository admin rights to rerun the failed job. |
Summary
Fixes #2034.
When OAuth refresh succeeds but
provider.saveTokens()fails,auth()should surface that persistence failure. The authorization server may already have rotated the refresh token, so silently falling through to a new authorization flow can hide the only useful error and leave the client with stale credentials.This keeps the existing fallback behavior for refresh request failures, but moves
saveTokens()out of that catch block so store/I/O failures propagate normally.To verify
pnpm --filter @modelcontextprotocol/client exec vitest run test/client/auth.test.ts -t "does not hide token persistence failures"pnpm --filter @modelcontextprotocol/client exec vitest run test/client/auth.test.tspnpm --filter @modelcontextprotocol/client typecheckpnpm --filter @modelcontextprotocol/client lintgit diff --checkThe repository pre-push hook also ran workspace typecheck, build, and lint successfully.