Skip to content

Playwright connectOverCDP() not working #9911

@jasonwillschiu

Description

@jasonwillschiu

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 [email protected]
  • 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions