MCPcopy Index your code
hub / github.com/codeaashu/claude-code / readAsync

Function readAsync

src/utils/secureStorage/macOsKeychainStorage.ts:67–96  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

65 return null
66 },
67 async readAsync(): Promise<SecureStorageData | null> {
68 const prev = keychainCacheState.cache
69 if (Date.now() - prev.cachedAt < KEYCHAIN_CACHE_TTL_MS) {
70 return prev.data
71 }
72 if (keychainCacheState.readInFlight) {
73 return keychainCacheState.readInFlight
74 }
75
76 const gen = keychainCacheState.generation
77 const promise = doReadAsync().then(data => {
78 // If the cache was invalidated or updated while we were reading,
79 // our subprocess result is stale — don't overwrite the newer entry.
80 if (gen === keychainCacheState.generation) {
81 // Stale-while-error — mirror read() above.
82 if (data === null && prev.data !== null) {
83 logForDebugging('[keychain] readAsync failed; serving stale cache', {
84 level: 'warn',
85 })
86 }
87 const next = data ?? prev.data
88 keychainCacheState.cache = { data: next, cachedAt: Date.now() }
89 keychainCacheState.readInFlight = null
90 return next
91 }
92 return data
93 })
94 keychainCacheState.readInFlight = promise
95 return promise
96 },
97 update(data: SecureStorageData): { success: boolean; warning?: string } {
98 // Invalidate cache before update
99 clearKeychainCache()

Callers

nothing calls this directly

Calls 2

doReadAsyncFunction · 0.85
logForDebuggingFunction · 0.85

Tested by

no test coverage detected