puppeteer: [Bug]: browser.newPage() and browser.pages hang because of Chromium crashes

Minimal, reproducible example

const browser = await puppeteer.launch({
      headless: true,
      args: [`--disable-extensions-except=${EXTENSION_PATH}`, `--load-extension=${EXTENSION_PATH`]
})

const page = await browser.newPage() or const pages = await browser.pages()

Background

I use Jest + Puppeteer + TS for e2e testing of my Chromium-based browser extension. I have ~220 tests in 9 different files, and 2-3 tests fail in each file because of Chromium crashes:

image

I use the latest Puppeteer (22.15.0), Jest (29.7.0), Fedora (40) and WebStorm IDE (2024.1.5). Unfortunately, I didn’t find a good way to work around this issue: there is no way to set a timeout for the newPage and pages method. Also, I understand it’s probably a browser issue, but I tried different browsers (Vivaldi, Brave, Opera), and they crashed during e2e tests. Still, they work fine in the system outside of e2e tests without any problem.

Expectation

I expected the code doesn’t hang.

Reality

It hangs, and the beforeEach method throws an exception: "Error: thrown: “Exceeded timeout of 15000 ms for a hook. Add a timeout value to this test to increase the timeout, if this is a long-running test. See https://jestjs.io/docs/api#testname-fn-timeout.”

Puppeteer configuration file (if used)

No response

Puppeteer version

22.15.0

Node version

20.12.2

Package manager

npm

Package manager version

10.8.2

Operating system

Linux

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 4
  • Comments: 26

Most upvoted comments

Have you tried setting https://pptr.dev/api/puppeteer.browserconnectoptions/#protocoltimeout to a lower value so that Puppeteer would time out before your test runner? Also, can you provide a minimal reproducible example for us to reproduce? If not, could you reproduce it with the official Chrome builds and submit a bug report to crbug.com/new with the crash ID from chrome://crashes?

I had a similar problem until i notice on puppeteer troubleshooting page this:

CAUTION - The current Chromium version in Alpine 3.20 is causing timeout issues with Puppeteer. Downgrading to Alpine 3.19 fixes the issue. See #11640, #12637, #12189

https://pptr.dev/troubleshooting#running-on-alpine

In my case i solved downgrading the alpine version of my app dockerfile, but the problem seems to affect newer versions of chromium and chrome browsers.

I suggest you to force puppeteer to use a slightly older version of the browser. For chrome here https://github.com/puppeteer/puppeteer/issues/12189 they point out that versions older than 123.0.6312.86 should work fine. (I have no idea which version of chromium would solve)

@OrKoN, Here is the link to the repo with a clean example: https://github.com/nikita-kov-dev/puppeteer-chrome-crash-reproduction. I added an empty extension (it contains only a manifest file and index.html) and the same e2e test configuration as for my project. When I run tests (Test.spec.ts file) from the WebStorm, Chrome crashes:

image

@OrKoN Yes, I have 32GB of RAM; 16 are in use. I have increased WebStorm’s memory to 8GB (it was 4GB before) and restarted it, but it didn’t resolve the issue. I use Vue3 for a relatively simple extension, but I will try to reproduce the problem with the most straightforward extension possible.

@OrKoN sure. Here is the console output from one of the crashes:

DevTools listening on ws://127.0.0.1:42449/devtools/browser/8894d5e9-90af-4b4c-b428-f7e7f65de8eb [1302855:1:0802/200315.589666:ERROR:v8_initializer.cc(815)] V8 process OOM (Failed to reserve virtual memory for CodeRange). [1302856:1:0802/200315.591892:ERROR:v8_initializer.cc(815)] V8 process OOM (Failed to reserve virtual memory for CodeRange).

@OrKoN I’ll provide a separate repo with a reproducible example ASAP, but I need some time to set it up.

Have you tried setting https://pptr.dev/api/puppeteer.browserconnectoptions/#protocoltimeout to a lower value so that Puppeteer would time out before your test runner? Also, can you provide a minimal reproducible example for us to reproduce? If not, could you reproduce it with the official Chrome builds and submit a bug report to crbug.com/new with the crash ID from chrome://crashes?

Thank you very much! I can handle Chrom(e|ium) crashes with protocolTimeout arg

Also, can you confirm which Chromium version you are using? Puppeteer v22.15.0 ships with a Chrome for Testing flavour and not Chromium

I tried installed version: Version 126.0.6478.182 (Official Build) Fedora Project (64-bit) and the default one (Chrome for Testing)