fix: surface playwright fallback remediation (#852)

Co-authored-by: Codex Agent <codex@hwlab.local>
This commit is contained in:
Lyon
2026-06-04 20:55:21 +08:00
committed by GitHub
parent eca9dbaa9c
commit 758c26a448
3 changed files with 30 additions and 7 deletions
+20 -6
View File
@@ -110,7 +110,7 @@ export async function browserDoctor() {
managedBrowser,
installCheck,
browser: browser.hwlabLaunchPlan ?? chromiumLaunchPlan(),
remediation: []
remediation: browserLaunchRemediation(browser.hwlabLaunchPlan ?? chromiumLaunchPlan(), { managedBrowser, installCheck })
};
}
@@ -196,17 +196,31 @@ export function chromiumLaunchPlan(env = process.env) {
export function classifyBrowserLaunchFailure(error) {
const message = error instanceof Error ? error.message : String(error);
if (/does not support chromium on/iu.test(message)) return "browser-install-unsupported-platform";
if (/Executable doesn't exist|download new browsers|playwright install/iu.test(message)) return "browser-cache-missing";
if (/spawn|ENOENT|permission denied|EACCES/iu.test(message)) return "browser-executable-unavailable";
return "browser-launch-failed";
}
export function browserLaunchRemediation(plan = chromiumLaunchPlan()) {
if (plan.executablePath) return [`using ${plan.executablePath}`];
return [
export function browserLaunchRemediation(plan = chromiumLaunchPlan(), context = {}) {
const remediation = [];
if (plan.executablePath) {
remediation.push(`using ${plan.executablePath}`);
if (context.managedBrowser?.cacheStatus === "missing") {
remediation.push("Playwright-managed browser cache is missing; the repo launcher selected system Chromium fallback.");
}
if (context.installCheck?.status) {
remediation.push(`Playwright install dry-run status=${context.installCheck.status}; keep using the repo launcher/system Chromium fallback when managed browser install is unavailable or unnecessary.`);
}
return remediation;
}
remediation.push(
"Set HWLAB_PLAYWRIGHT_CHROMIUM=/snap/bin/chromium when system Chromium exists.",
"Install Playwright browsers with npx playwright install when no system Chromium is available."
];
context.installCheck?.status === "unsupported"
? "Playwright install is unsupported on this platform; install a system Chromium package or use a runner image that already contains Chromium."
: "Install Playwright browsers with npx playwright install when no system Chromium is available."
);
return remediation;
}
function normalizePlaywrightModule(module) {