Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Playwright connectOverCDP() not working #9911

Open
jasonwillschiu opened this issue Apr 4, 2024 · 3 comments
Open

Playwright connectOverCDP() not working #9911

jasonwillschiu opened this issue Apr 4, 2024 · 3 comments
Labels
bug Something isn't working needs repro Needs an example to reproduce

Comments

@jasonwillschiu
Copy link

What version of Bun is running?

1.1.0+5903a6141

What platform is your computer?

Darwin 23.4.0 arm64 arm

What steps can reproduce the bug?

I'm trying to use Playwright's connectOverCDP to access an existing Chrome browser in debug mode. This is for a web scraping project. I've returned to Nodejs and everything works fine, but keen to try bun more.

My setup

  • M1 Arm Mac
  • Bun 1.1
  • Playwright playwright@1.42.1
  • Chrome Version 123.0.6312.107 (Official Build) (arm64)

I run chrome using:
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222 --no-first-run --no-default-browser-check --user-data-dir=chrome-user-data-dir --profile-directory=Default

Code:

import { chromium } from 'playwright';
const browser = await chromium.connectOverCDP('http://localhost:9222');
const defaultContext = browser.contexts()[0];
const page = await defaultContext.newPage();
page.goto('https://google.com')
await page.waitForTimeout(5000);
await browser.close();

Bun Error message:

ConnectionRefused: overCDP: Unable to connect. Is the computer able to access the url?
Call log:
  - <ws preparing> retrieving websocket url from http://localhost:9222

In Nodejs it connects and works as expected.

Thanks for all your great work!
Jason

What is the expected behavior?

A new Chrome tab is opened to google.com and then closed after 5 seconds.

What do you see instead?

Bun Error message:

ConnectionRefused: overCDP: Unable to connect. Is the computer able to access the url?
Call log:
  - <ws preparing> retrieving websocket url from http://localhost:9222

Additional information

No response

@jasonwillschiu jasonwillschiu added the bug Something isn't working label Apr 4, 2024
@rossanmol
Copy link

Experiencing same issue :/

@sohaieb
Copy link

sohaieb commented Apr 9, 2024

I faced the same issue here as well

@blackfan23
Copy link

I have set up a repo here:
https://github.com/blackfan23/bun-test-playwright

It uses nx and has 3 test cases (see readme)

  1. node + playwright (connects fine)
  2. bun + puppeteer (connects fine)
  3. bun + playwright (does not work)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs repro Needs an example to reproduce
Projects
None yet
Development

No branches or pull requests

5 participants