-
Notifications
You must be signed in to change notification settings - Fork 18
Improve doctor.mjs Playwright browser check with distinct failure modes #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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', | ||
| }; | ||
| } | ||
|
|
||
| // 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
|
||
| } | ||
|
|
||
There was a problem hiding this comment.
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
catchand always reports "Playwright package not available" with the genericnpm installfix. 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 missingplaywright); otherwise surface a distinct failure label (ideally includingerr.message) so users aren’t sent to the wrong fix.