fix(client): surface OAuth token persistence failures#2121
Conversation
🦋 Changeset detectedLatest commit: c35d16f The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
@modelcontextprotocol/client
@modelcontextprotocol/codemod
@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. |
34c5df5 to
c35d16f
Compare
|
Rebased onto current main, added the client patch changeset, and force-pushed c35d16f. Local validation: changeset status shows @modelcontextprotocol/client patch; client auth.test.ts passed with 168 tests; client typecheck and lint passed; git diff --check passed. Pre-push typecheck, build, and lint also passed. |
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.