fix: support puppeteer@25#3869
Merged
Merged
Conversation
Puppeteer 25 is ESM-only and its bundled Chrome changes a few behaviors. This keeps compatibility with older versions: - suppress the type-only ESM import errors the same way we do for got-scraping - map the removed `clickCount` click option to its `count` replacement in `clickElements()` (both are passed through, so older versions keep working) - set a `User-Agent` header from `gotoExtended()` via `page.setUserAgent()`, since newer Chrome ignores it in `setExtraHTTPHeaders()` - normalize the new `sameSite: 'Default'` cookie value to undefined in the session cookies
Puppeteer 25 can hang `page.close()` indefinitely when the page's navigation was aborted (e.g. on a navigation timeout), and the request cleanup awaited it without any guard, blocking the crawler forever. Bound it with a 5s timeout.
…rors Unlike `@ts-expect-error`, it is inert when there is nothing to suppress, so the repo compiles against both puppeteer 24 (CJS) and 25+ (ESM only).
barjin
approved these changes
Jul 17, 2026
barjin
left a comment
Member
There was a problem hiding this comment.
I'll trust you with the ESM setup, the rest of the code looks ok (aside from this one nit ⬇️ ).
Approving now as it's not a critical bug, but please look into it before merging. Thanks!
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.
Puppeteer 25 is ESM-only, requires Node 22.12+, and its bundled Chrome changes a few behaviors. This adds support for it while keeping compatibility with older versions:
@ts-ignorecomments (same approach as for got-scraping), so the code compiles against both puppeteer 24 (CJS) and 25+ (ESM-only) — the published.d.tsshape is unchangedclickCountclick option to itscountreplacement inclickElements(), passing both through so older versions keep workingUser-Agentheader fromgotoExtended()viapage.setUserAgent(), since newer Chrome ignores it insetExtraHTTPHeaders()sameSite: 'Default'cookie value toundefinedin session cookiespage.close()call in request cleanup with a 5s timeout — puppeteer 25 can hang it indefinitely when the page's navigation was aborted (e.g. on a navigation timeout), which blocked the crawler foreverNo new runtime version detection was needed — the existing
CdpBrowser/package.jsonchecks still work with v25, andrequire('puppeteer')works there because v25's minimum Node hasrequire(esm).Everything is verified locally against both puppeteer 24.36.1 and 25.3.0 (build, type checks, and the full puppeteer test suites, including under CPU load for the timeout tests).
Supersedes #3772.