chore: install browser with @puppeteer/browsers#10306
Merged
ruifigueira merged 2 commits intomainfrom Aug 13, 2025
Merged
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
ruifigueira
commented
Aug 10, 2025
ace5b95 to
77e2976
Compare
77e2976 to
fdae05d
Compare
simonabadoiu
approved these changes
Aug 12, 2025
petebacondarwin
approved these changes
Aug 13, 2025
Contributor
petebacondarwin
left a comment
There was a problem hiding this comment.
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("puppeteer@22.8.2")` 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
petebacondarwin
approved these changes
Aug 13, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 devand trigger thelaunchfunction, 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-importis already installed, when we runnpxImport("puppeteer@22.8.2")it will just skip the installation, and therefore it won't call thepostinstallscript associated with that package that actually installs and caches the browser.