MCPcopy Create free account
hub / github.com/claude-code-best/claude-code / invalidateOAuthCacheIfDiskChanged

Function invalidateOAuthCacheIfDiskChanged

src/utils/auth.ts:1316–1332  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1314// then revokes terminal 1 server-side, and terminal 1's memoize never
1315// re-reads — infinite /login regress (CC-1096, GH#24317).
1316async function invalidateOAuthCacheIfDiskChanged(): Promise<void> {
1317 try {
1318 const { mtimeMs } = await stat(
1319 join(getClaudeConfigHomeDir(), '.credentials.json'),
1320 )
1321 if (mtimeMs !== lastCredentialsMtimeMs) {
1322 lastCredentialsMtimeMs = mtimeMs
1323 clearOAuthTokenCache()
1324 }
1325 } catch {
1326 // ENOENT — macOS keychain path (file deleted on migration). Clear only
1327 // the memoize so it delegates to the keychain cache's 30s TTL instead
1328 // of caching forever on top. `security find-generic-password` is
1329 // ~15ms; bounded to once per 30s by the keychain cache.
1330 getClaudeAIOAuthTokens.cache?.clear?.()
1331 }
1332}
1333
1334// In-flight dedup: when N claude.ai proxy connectors hit 401 with the same
1335// token simultaneously (common at startup — #20930), only one should clear

Callers 1

Calls 3

statFunction · 0.85
clearOAuthTokenCacheFunction · 0.85
clearMethod · 0.45

Tested by

no test coverage detected