Skip to content

fix: support puppeteer@25#3869

Merged
B4nan merged 5 commits into
masterfrom
fix/puppeteer-v25
Jul 17, 2026
Merged

fix: support puppeteer@25#3869
B4nan merged 5 commits into
masterfrom
fix/puppeteer-v25

Conversation

@B4nan

@B4nan B4nan commented Jul 17, 2026

Copy link
Copy Markdown
Member

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:

  • suppress the type-only ESM import errors with inert @ts-ignore comments (same approach as for got-scraping), so the code compiles against both puppeteer 24 (CJS) and 25+ (ESM-only) — the published .d.ts shape is unchanged
  • map the removed clickCount click option to its count replacement in clickElements(), passing both 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 session cookies
  • bound the page.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 forever

No new runtime version detection was needed — the existing CdpBrowser/package.json checks still work with v25, and require('puppeteer') works there because v25's minimum Node has require(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.

B4nan added 4 commits July 16, 2026 20:52
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).
@B4nan B4nan added the adhoc Ad-hoc unplanned task added during the sprint. label Jul 17, 2026
@github-actions github-actions Bot added this to the 145th sprint - Tooling team milestone Jul 17, 2026
@github-actions github-actions Bot added t-tooling Issues with this label are in the ownership of the tooling team. tested Temporary label used only programatically for some analytics. labels Jul 17, 2026
@B4nan
B4nan requested a review from barjin July 17, 2026 07:39

@barjin barjin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

Comment thread packages/puppeteer-crawler/src/internals/utils/puppeteer_utils.ts
@B4nan
B4nan merged commit 1430062 into master Jul 17, 2026
8 checks passed
@B4nan
B4nan deleted the fix/puppeteer-v25 branch July 17, 2026 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

adhoc Ad-hoc unplanned task added during the sprint. t-tooling Issues with this label are in the ownership of the tooling team. tested Temporary label used only programatically for some analytics.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants