Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions doctor.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,34 @@ function checkDependencies() {
}

async function checkPlaywright() {
// Step 1: Check if the playwright package can be imported
let chromium;
try {
const pw = await import('playwright');
chromium = pw.chromium;
} catch {
return {
pass: false,
label: 'Playwright package not available',
fix: 'Run: npm install',
Comment on lines +50 to +54

Copilot AI Apr 10, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The import stage uses a bare catch and always reports "Playwright package not available" with the generic npm install fix. This will misdiagnose other import-time failures (e.g., corrupted install, unsupported platform/architecture, or other runtime errors). Capture the thrown error and only treat it as "package not available" when it’s a module-not-found case (e.g., err.code === 'ERR_MODULE_NOT_FOUND' / message indicates missing playwright); otherwise surface a distinct failure label (ideally including err.message) so users aren’t sent to the wrong fix.

Suggested change
} catch {
return {
pass: false,
label: 'Playwright package not available',
fix: 'Run: npm install',
} catch (err) {
const errCode = err && typeof err === 'object' ? err.code : undefined;
const errMessage = err instanceof Error ? err.message : String(err);
const isModuleNotFound =
errCode === 'ERR_MODULE_NOT_FOUND' ||
/cannot find package ['"]playwright['"]/i.test(errMessage) ||
/cannot find module ['"]playwright['"]/i.test(errMessage) ||
/module ['"]playwright['"] was not found/i.test(errMessage);
if (isModuleNotFound) {
return {
pass: false,
label: 'Playwright package not available',
fix: 'Run: npm install',
};
}
return {
pass: false,
label: `Playwright import failed: ${errMessage}`,

Copilot uses AI. Check for mistakes.
};
}

// Step 2: Check if the Chromium browser binary is installed
try {
const { chromium } = await import('playwright');
const execPath = chromium.executablePath();
if (existsSync(execPath)) {
return { pass: true, label: 'Playwright chromium installed' };
return { pass: true, label: `Playwright Chromium browser installed (${execPath})` };
}
return {
pass: false,
label: 'Playwright chromium not installed',
label: 'Playwright Chromium browser not installed',
fix: 'Run: npx playwright install chromium',
};
} catch {
return {
pass: false,
label: 'Playwright chromium not installed',
label: 'Playwright Chromium browser not installed',
fix: 'Run: npx playwright install chromium',
};
Comment on lines 59 to 74

Copilot AI Apr 10, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Chromium check’s catch treats any exception as "browser not installed". If chromium.executablePath() throws for reasons other than a missing browser (e.g., Playwright internal error), the output will point to npx playwright install chromium even though that may not resolve it. Capture the error and report a separate failure mode (or include err.message) so this stage only claims "not installed" when the binary is actually absent.

Copilot uses AI. Check for mistakes.
}
Expand Down