question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature proposal: Ability to pass browserUrl to puppeteer.connect

See original GitHub issue

Description

Add support for new browserUrl property in options object passed to puppeteer.connect(options). It would accept url in form of http://{host}:{port} which should point to the existing Chromium instance. For example:

puppeteer.connect({
    browserUrl: http://localhost:9222
})

If this option is passed to puppeteer.connect, then browserWSEndpoint is retrieved from http://{host}:{port}/json/version and passed new Connection(). The rest of the flow remains unchanged.

If you’re OK with the proposal I could write up the code and the tests

Background

Currently to attach Puppeteer to an existing Chrome instance, one must provide url of browser websocket endpoint. For example:

puppeteer.connect({
    browserWSEndpoint: ws://localhost:9222/devtools/browser/b0b8a4fb-bb17-4359-9533-a8d9f3908bd8
})

However, as many issues raised here show (#2790, #1645, #940) browserWSEndpoint is often not known to the code calling puppeteer.connect, for example because Chrome was lunched in a docker container.

In such a case, a common and repeating scenario is to:

  1. make HTTP request to http://{host}:{port}/json/version
  2. parse the response JSON
  3. get browserWSEndpoint from and use it in puppeteer.connect

The steps above could be done by puppeteer resulting in less code in the user-land.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:4
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
lukaszfiszercommented, Dec 4, 2018

@andrejska my PR #3558 is ready and awaiting review

0reactions
sublimatorcommented, Mar 4, 2022

How does one do this for Firefox? (After say using web-ext run to launch Firefox with an extension)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Connecting Puppeteer to Existing Chrome Window w - Medium
The answer is Puppeteer and its ability to connect to an existing Chrome Window which you've already manually logged into.
Read more >
Connecting Browsers in Puppeteer - Stack Overflow
The answer is Yes and No. You can connect to an existing using the connect function: const browserURL = 'http://127.0.0.1:21222'; ...
Read more >
puppeteer 1.12.0 on Node.js Yarn - NewReleases.io
New release puppeteer version 1.12.0 on Node.js Yarn. ... #3537 - Feature proposal: Ability to pass browserUrl to puppeteer.connect; #3562 - Better error ......
Read more >
Puppeteer documentation - DevDocs
A Browser is created when Puppeteer connects to a Chromium instance, ... await puppeteer.launch(); // Store the endpoint to be able to reconnect...
Read more >
puppeteer-core: Versions - Openbase
With Chromium, Puppeteer will now attach to page/iframe targets immediately to ... #3537 - Feature proposal: Ability to pass browserUrl to puppeteer.connect ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found