-
Notifications
You must be signed in to change notification settings - Fork 970
chore: install browser with @puppeteer/browsers #10306
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
Conversation
🦋 Changeset detectedLatest commit: 038071a The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
create-cloudflare
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-editor-shared
wrangler
commit: |
01ac5ec
to
00297d4
Compare
ace5b95
to
77e2976
Compare
77e2976
to
fdae05d
Compare
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.
I like this approach! Gets the minimal install (similar to npx-import) for people not using browser-rendering, while having reliable on-demand install for users that do, with caching!
Browser installation relied on a postinstall script from puppeteer package which was unreliable with npx-import. For instance, if we have a workers project with browser binding that doesn't explicitly include `puppeteer`, the first time we run it it with `npx wrangler dev` and trigger the `launch` function, it will install the browser and cache it under `~/.cache/puppeteer`. But if for some reason we delete the cached browser (e.g., we run `npx puppeteer browsers clear`), and we try to run it the same way as above, it will fail with: ``` Error: Could not find Chrome (ver. 124.0.6367.207). This can occur if either 1. you did not perform an installation before running the script (e.g. `npx puppeteer browsers install chrome`) or 2. your cache path is incorrectly configured (which is: /Users/rfigueira/.cache/puppeteer). For (2), check out our guide on configuring puppeteer at https://pptr.dev/guides/configuration. at ChromeLauncher.resolveExecutablePath (/Users/rfigueira/.npm/_npx/9c191fc107e155e1/node_modules/puppeteer-core/lib/cjs/puppeteer/node/ProductLauncher.js:295:27) at ChromeLauncher.executablePath (/Users/rfigueira/.npm/_npx/9c191fc107e155e1/node_modules/puppeteer-core/lib/cjs/puppeteer/node/ChromeLauncher.js:209:25) at ChromeLauncher.computeLaunchArguments (/Users/rfigueira/.npm/_npx/9c191fc107e155e1/node_modules/puppeteer-core/lib/cjs/puppeteer/node/ChromeLauncher.js:89:37) at async ChromeLauncher.launch (/Users/rfigueira/.npm/_npx/9c191fc107e155e1/node_modules/puppeteer-core/lib/cjs/puppeteer/node/ProductLauncher.js:70:28) at async #handleLoopback (/Users/rfigueira/dev/tmp/puppeteer-test/node_modules/wrangler/node_modules/miniflare/dist/src/index.js:25418:25) ``` After deleting the browser, and because `npx-import` is already installed, when we run `npxImport("[email protected]")` it will just skip the installation, and therefore it won't call the `postinstall` script associated with that package that actually installs and caches the browser.
fdae05d
to
98d16c2
Compare
Browser installation relied on a postinstall script from puppeteer package which was unreliable with npx-import.
For instance, if we have a workers project with browser binding that doesn't explicitly include
puppeteer
, the first time we run it it withnpx wrangler dev
and trigger thelaunch
function, it will install the browser and cache it under~/.cache/puppeteer
.But if for some reason we delete the cached browser (e.g., we run
npx puppeteer browsers clear
), and we try to run it the same way as above, it will fail with:After deleting the browser, and because
npx-import
is already installed, when we runnpxImport("[email protected]")
it will just skip the installation, and therefore it won't call thepostinstall
script associated with that package that actually installs and caches the browser.