()
| 271 | * Resolution: env var -> cached download -> system Chrome. |
| 272 | */ |
| 273 | export async function findBrowser(): Promise<BrowserResult | undefined> { |
| 274 | const fromEnv = findFromEnv(); |
| 275 | if (fromEnv) return fromEnv; |
| 276 | |
| 277 | const fromCache = await findFromCache(); |
| 278 | if (fromCache.result) return fromCache.result; |
| 279 | if (fromCache.staleHyperframesCachePath) { |
| 280 | console.warn( |
| 281 | `[browser] Cached binary missing at ${fromCache.staleHyperframesCachePath} — re-downloading...`, |
| 282 | ); |
| 283 | try { |
| 284 | return await downloadBrowser(); |
| 285 | } catch (err) { |
| 286 | const cause = normalizeErrorMessage(err); |
| 287 | throw new Error( |
| 288 | `Cached Chrome binary was missing at ${fromCache.staleHyperframesCachePath}, and re-download failed: ${cause}\n` + |
| 289 | `Run \`hyperframes browser ensure --force\` to re-download.`, |
| 290 | ); |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | const fromSystem = findFromSystem(); |
| 295 | if (fromSystem) { |
| 296 | warnSystemFallbackOnce(fromSystem.executablePath); |
| 297 | } |
| 298 | return fromSystem; |
| 299 | } |
| 300 | |
| 301 | /** |
| 302 | * On Linux ARM64, attempt to auto-install system Chromium if not found. |
no test coverage detected