refactor: improve Chrome launcher error handling in browser detection

This commit is contained in:
Emil Neander 2025-03-06 12:36:03 +01:00
parent 4f7eefaa20
commit 246566c258

View File

@ -360,9 +360,18 @@ async function findBrowserExecutablePath(): Promise<string> {
console.log("Chrome launched but couldn't determine executable path");
}
} catch (error) {
// Check if it's a ChromeNotInstalledError
const errorMessage = error instanceof Error ? error.message : String(error);
if (
errorMessage.includes("No Chrome installations found") ||
(error as any)?.code === "ERR_LAUNCHER_NOT_INSTALLED"
) {
console.log("Chrome not installed. Falling back to manual detection");
} else {
console.error("Failed to find Chrome using chrome-launcher:", error);
console.log("Falling back to manual detection");
}
}
// If chrome-launcher failed, use manual detection