Skip to content

fix(desktop): auto-install Playwright Chromium browser on first launch - #22

Merged
kjxcodez merged 1 commit into
mainfrom
fix/playwright-browser-auto-install
Aug 5, 2026
Merged

fix(desktop): auto-install Playwright Chromium browser on first launch#22
kjxcodez merged 1 commit into
mainfrom
fix/playwright-browser-auto-install

Conversation

@kjxcodez

@kjxcodez kjxcodez commented Aug 5, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes #21

On a fresh desktop install, users had no Playwright Chromium binary and every scraper:maps job failed immediately with:

browserType.launch: Executable doesn't exist at ...ms-playwright\chromium_headless_shell-1228\...

This PR adds an automatic one-time browser installation that runs during app startup — fully transparent to the user via splash screen progress — so scraping works out of the box on any machine.


Changes

lib/playwright-setup.ts (new)

Export Purpose
getPlaywrightBrowsersPath() Returns {userData}/playwright-browsers — a stable, app-controlled path with guaranteed write access
isBrowserInstalled() Uses playwright-core's own path resolver to check for the binary without hard-coding versioned folder names
installPlaywrightBrowsers(onProgress?) Forks playwright-core/cli.js install chromium — no dependency on npx or any global tool; streams stdout to an optional progress callback
ensurePlaywrightBrowsers(onProgress?) Main entry point: sets PLAYWRIGHT_BROWSERS_PATH, checks if installed, installs only if missing

main/index.ts

  • Made app.whenReady() callback async
  • Added ensurePlaywrightBrowsers() call between migrations and IPC registration, wired to updateSplashProgress so the splash screen shows "Setting up browser engine..." during first-launch download

services/scheduler.ts

  • Added PLAYWRIGHT_BROWSERS_PATH to the worker fork() env whitelist so every worker finds the binary in the app-controlled path rather than the missing OS-wide cache

Behaviour

Scenario Before After
Fresh install, scraper job Fails immediately with "Executable doesn't exist" App downloads Chromium at startup; job succeeds
Existing install N/A Check takes < 10 ms; startup time unchanged
Multiple workers spawned simultaneously Each worker would independently fail All workers read PLAYWRIGHT_BROWSERS_PATH set by main process
Browser install fails (e.g. no network) N/A Error is logged; app continues; scraper jobs report an actionable error

Testing

  • TypeScript types pass (pnpm check-types — 0 errors)
  • Manual: delete %APPDATA%\@leadforge\playwright-browsers → launch app → observe splash shows browser setup → run scraper job → succeeds

Closes #21

- Add lib/playwright-setup.ts with ensurePlaywrightBrowsers() that checks
  for the chromium binary at startup and downloads it via playwright-core
  CLI if missing. Browser is stored in {userData}/playwright-browsers so
  the app fully controls the install location with no admin rights needed.
- Call ensurePlaywrightBrowsers() in index.ts app.whenReady() callback,
  wiring progress output into the splash screen label so users see
  'Setting up browser engine...' on first launch rather than a silent hang.
- Forward PLAYWRIGHT_BROWSERS_PATH in scheduler.ts worker fork() env so
  every spawned worker process resolves the binary from the same
  app-controlled location instead of the OS-wide ms-playwright cache.
@vercel

vercel Bot commented Aug 5, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Actions Updated (UTC)
leadforge-os-api Skipped Skipped Aug 5, 2026 6:56pm
leadforge-os-marketing Skipped Skipped Aug 5, 2026 6:56pm

@kjxcodez
kjxcodez merged commit 82ad3e1 into main Aug 5, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: Playwright browser executable missing on fresh desktop installs

1 participant