Skip to content

Commit e735749

Browse files
fix: surface fallback failures and bound stalled requests
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
1 parent 3447b49 commit e735749

3 files changed

Lines changed: 628 additions & 30 deletions

File tree

src/credentials.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,13 +328,14 @@ export function getCredentialsForSync(): ClaudeCredentials | null {
328328
return null
329329
}
330330

331-
export function getCachedCredentials(): ClaudeCredentials | null {
331+
export function getCachedCredentials(forceRefresh = false): ClaudeCredentials | null {
332332
const account = getActiveAccount()
333333
if (!account) return null
334334

335335
const now = Date.now()
336336
const cached = accountCacheMap.get(account.source)
337337
if (
338+
!forceRefresh &&
338339
cached &&
339340
now - cached.cachedAt < CREDENTIAL_CACHE_TTL_MS &&
340341
cached.creds.expiresAt > now + 60_000
@@ -346,9 +347,25 @@ export function getCachedCredentials(): ClaudeCredentials | null {
346347
return cached.creds
347348
}
348349

350+
if (forceRefresh) {
351+
log("cache_bypass", {
352+
source: account.source,
353+
reason: "forced_reload",
354+
})
355+
accountCacheMap.delete(account.source)
356+
const reloaded = refreshAccount(account.source)
357+
if (reloaded) {
358+
account.credentials = reloaded
359+
}
360+
}
361+
349362
log("cache_miss", {
350363
source: account.source,
351-
reason: cached ? "stale or expiring" : "empty",
364+
reason: forceRefresh
365+
? "forced_reload"
366+
: cached
367+
? "stale or expiring"
368+
: "empty",
352369
})
353370

354371
const fresh = refreshIfNeeded(account)

0 commit comments

Comments
 (0)