puppeteer: [Bug]: await browser.pages() hanging when used with remote connection (puppeteer.connect)
Minimal, reproducible example
import puppeteer from 'puppeteer'
;(async()=>{
const browser = await puppeteer.connect({
browserURL: 'http://localhost:9222',
defaultViewport: null,
})
const pages = await browser.pages()
console.log(pages) // STUCK š
})()
Error string
no error
Background
Launch chrome with --remote-debugging-port=9222
chrome --remote-debugging-port=9222
On Mac:
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222
OTHER PEOPLE ARE EXPERIENCING THIS ISSUE: https://stackoverflow.com/questions/77540484/browser-pages-does-not-resolve-in-puppeteer-script
Expectation
Return the pages array for all browser contexts.
However, I also attempted doing it only for browser.defaultBrowserContext(), but it was the same bug in that case.
Reality
Hanging, stuck, no error messages.
browser.pages() works when using puppeteer.launch()
Puppeteer version
21.7.0
Node version
21.5.0
Package manager
npm
Package manager version
10.2.5
Operating system
macOS
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 28 (1 by maintainers)
Commits related to this issue
- Remove --single-process flag This flag is causing Puppeteer to hang on recent Alpine / Chromium, see: https://github.com/puppeteer/puppeteer/issues/11640#issuecomment-2243267991 https://github.com/p... — committed to Contractbook/puppeteer-pdf by gmile 2 years ago
- Update dependencies This change updates the dependency versions of: - debian-bookworm - pandoc - pandoc-crossref - puppeteer - imgur - mermaid-filter - typescript - drawio It also resolves an issue... — committed to TrustedComputingGroup/pandoc by chrisfenner 2 years ago
- Update dependencies (#155) This change updates the dependency versions of: - debian-bookworm - pandoc - pandoc-crossref - puppeteer - imgur - mermaid-filter - typescript - drawio It also... — committed to TrustedComputingGroup/pandoc by chrisfenner 2 years ago
We have seen success in preventing this on alpine 3.20 by adding a
--disable-gpuflag into the launch args, e.g.Will time out and fail with
ProtocolError: Network.enable timed outWhereas, adding the flag, e.g.
Outputs the expected results, we are currently assuming that chromium updated something GPU related in 127+ but are too busy trying test the fix!
We just started seeing this exact error today, but only on EC2 instances in AWS. We have a dockerized API server thatās pulling in some assets from an S3 bucket. Iāve verified that a curl command DOES work, so itās not a network problem. And Iāve verified that the EC2 instance AND the docker container on that instance can see the stuff on the S3 bucket. This has been working for years, and just started throwing this error and not producing the expected PDF files last night.
We are not using --single-process, so that wasnāt a fix for us. We ARE in the Alpine docker container, but I donāt have a good way to test switching to Debian as this app is very extensive. I see this issue is closed, but we are still experiencing it, but again, not on local development environments, only on the test/stage/prod environments we have in AWS.
Any ideas?? Weāve tried so many things, even going back to the previous sprint release of our own code and database, which DID work as of yesterday, but today, no dice.
Any help is appreciate.
The fix that @CeeBeeUK suggested fixed my issue. At the time of writing this my Dockerfile uses
FROM node:21-alpineand the current alpine version is 3.20.Adding
--disable-gpufixed this. e.g.Thanks for mentioning this workaround. While locally and with kvm there were no problems with chrome 127.x (Ubuntu based), k8s pods did show this error (debian based image) - ādisable-gpuā did help here too.
related issue from alpine aports
I am able to reliably reproduce the error from original issue using a docker image & pdf rendering on an Alpine 3.20, but not on debian.
Hereās my Dockerfile:
Then:
The
docker runcommand will hang for 2-3 minutes, then finish render an exception:While the command is running, I observe unusually high CPU usage by chromium process.
Updating the Dockerfile to be debian-based fixes the issue: