()
| 67 | * immediately after startMdmRawRead(). Non-darwin is a no-op. |
| 68 | */ |
| 69 | export function startKeychainPrefetch(): void { |
| 70 | if (process.platform !== 'darwin' || prefetchPromise || isBareMode()) return |
| 71 | |
| 72 | // Fire both subprocesses immediately (non-blocking). They run in parallel |
| 73 | // with each other AND with main.tsx imports. The await in Promise.all |
| 74 | // happens later via ensureKeychainPrefetchCompleted(). |
| 75 | const oauthSpawn = spawnSecurity( |
| 76 | getMacOsKeychainStorageServiceName(CREDENTIALS_SERVICE_SUFFIX), |
| 77 | ) |
| 78 | const legacySpawn = spawnSecurity(getMacOsKeychainStorageServiceName()) |
| 79 | |
| 80 | prefetchPromise = Promise.all([oauthSpawn, legacySpawn]).then( |
| 81 | ([oauth, legacy]) => { |
| 82 | // Timed-out prefetch: don't prime. Sync read/spawn will retry with its |
| 83 | // own (longer) timeout. Priming null here would shadow a key that the |
| 84 | // sync path might successfully fetch. |
| 85 | if (!oauth.timedOut) primeKeychainCacheFromPrefetch(oauth.stdout) |
| 86 | if (!legacy.timedOut) legacyApiKeyPrefetch = { stdout: legacy.stdout } |
| 87 | }, |
| 88 | ) |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * Await prefetch completion. Called in main.tsx preAction alongside |
no test coverage detected