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