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

[Bug]: WSS Connection to Browserless Hangs #11268

Closed
2 tasks
jwkuo opened this issue Oct 27, 2023 · 8 comments
Closed
2 tasks

[Bug]: WSS Connection to Browserless Hangs #11268

jwkuo opened this issue Oct 27, 2023 · 8 comments

Comments

@jwkuo
Copy link

jwkuo commented Oct 27, 2023

Minimal, reproducible example

import puppeteer from 'puppeteer';

const main = async () => {
  try {
    const browser = await puppeteer.connect({
      browserWSEndpoint: `wss://chrome.browserless.io?token=${process.env.BROWSERLESS_TOKEN}`
    });

  } catch (error) {
    console.log('ERROR: ' + error.message);
  }
}

main();

Error string

no error

Bug behavior

  • Flaky
  • PDF

Background

Version 21.4.1 hangs when connecting via secure websocket to Browserless. Version 21.3.8 successfully connects and sets browser for further interaction.

Expectation

Puppeteer should connect and set the browser const for further interaction.

Reality

The script hangs indefinitely.

Puppeteer configuration file (if used)

No response

Puppeteer version

21.4.1

Node version

18.18.2

Package manager

npm

Package manager version

9.8.1

Operating system

Linux

@github-actions
Copy link

The issue has been labeled as confirmed by the automatic analyser.
Someone from the Puppeteer team will take a look soon!


Analyzer run

@Flysky12138
Copy link

puppeteer-core: ^21.4.1 me too

@OrKoN
Copy link
Collaborator

OrKoN commented Oct 30, 2023

Interesting. Is there a way for us to test it without the creation of the browserless account?

@OrKoN
Copy link
Collaborator

OrKoN commented Oct 30, 2023

Alternatively, could you provide the CDP log by running with the env var DEBUG=puppeteer:*?

@jwkuo
Copy link
Author

jwkuo commented Oct 30, 2023

Unfortunately, Browserless doesn't have an endpoint that doesn't require a token. They do have a free tier that would suffice for troubleshooting. Here is the debug output:

  puppeteer:protocol:SEND ► [ '{"method":"Browser.getVersion","id":1}' ] +0ms
  puppeteer:protocol:RECV ◀ [
  puppeteer:protocol:RECV ◀   '{"id":1,"result":{"protocolVersion":"1.3","product":"HeadlessChrome/113.0.5672.63","revision":"@0e1a4471d5ae5bf128b1bd8f4d627c8cbd55f70c","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/113.0.5672.63 Safari/537.36","jsVersion":"11.3.244.8"}}'
  puppeteer:protocol:RECV ◀ ] +0ms
  puppeteer:protocol:SEND ► [ '{"method":"Target.getBrowserContexts","id":2}' ] +0ms
  puppeteer:protocol:RECV ◀ [ '{"id":2,"result":{"browserContextIds":[]}}' ] +0ms
  puppeteer:protocol:SEND ► [
  puppeteer:protocol:SEND ►   '{"method":"Target.setDiscoverTargets","params":{"discover":true,"filter":[{}]},"id":3}'
  puppeteer:protocol:SEND ► ] +0ms
  puppeteer:protocol:RECV ◀ [
  puppeteer:protocol:RECV ◀   '{"method":"Target.targetCreated","params":{"targetInfo":{"targetId":"758B8FB66B7B74F3723A43ABA6B06429","type":"page","title":"about:blank","url":"about:blank","attached":true,"canAccessOpener":false,"browserContextId":"6F812D5B1EC62C6B30066B9CCC6AE980"}}}'
  puppeteer:protocol:RECV ◀ ] +0ms
  puppeteer:protocol:RECV ◀ [
  puppeteer:protocol:RECV ◀   '{"method":"Target.targetCreated","params":{"targetInfo":{"targetId":"7c1db49d-604a-4fa2-a71b-244fa634cae8","type":"browser","title":"","url":"","attached":true,"canAccessOpener":false}}}'
  puppeteer:protocol:RECV ◀ ] +0ms
  puppeteer:protocol:RECV ◀ [
  puppeteer:protocol:RECV ◀   '{"method":"Target.targetCreated","params":{"targetInfo":{"targetId":"AB5FCE1FC92064CBC5694832F98442AC","type":"tab","title":"about:blank","url":"about:blank","attached":false,"canAccessOpener":false,"browserContextId":"6F812D5B1EC62C6B30066B9CCC6AE980"}}}'
  puppeteer:protocol:RECV ◀ ] +0ms
  puppeteer:protocol:RECV ◀ [
  puppeteer:protocol:RECV ◀   '{"method":"Target.targetCreated","params":{"targetInfo":{"targetId":"de034c6c-5227-44dd-ad82-bbfc7ac33823","type":"browser","title":"","url":"","attached":false,"canAccessOpener":false}}}'
  puppeteer:protocol:RECV ◀ ] +0ms
  puppeteer:protocol:RECV ◀ [
  puppeteer:protocol:RECV ◀   '{"method":"Target.targetCreated","params":{"targetInfo":{"targetId":"f90d6712-9093-4ab6-af7c-1f5230f83507","type":"browser","title":"","url":"","attached":true,"canAccessOpener":false}}}'
  puppeteer:protocol:RECV ◀ ] +0ms
  puppeteer:protocol:RECV ◀ [ '{"id":3,"result":{}}' ] +0ms
  puppeteer:protocol:SEND ► [
  puppeteer:protocol:SEND ►   '{"method":"Target.setAutoAttach","params":{"waitForDebuggerOnStart":true,"flatten":true,"autoAttach":true,"filter":[{"type":"page","exclude":true},{}]},"id":4}'
  puppeteer:protocol:SEND ► ] +0ms
  puppeteer:protocol:RECV ◀ [ '{"id":4,"result":{}}' ] +0ms

@OrKoN
Copy link
Collaborator

OrKoN commented Oct 30, 2023

@jwkuo interesting, it looks like the browser does not attach any targets on Target.setAutoAttach and AB5FCE1FC92064CBC5694832F98442AC needs to be auto attached. HeadlessChrome/113 looks like an outdated version. The latest Puppeteer requires at least 118.0.5993.70. See https://pptr.dev/chromium-support

@OrKoN OrKoN closed this as not planned Won't fix, can't repro, duplicate, stale Oct 30, 2023
@jwkuo
Copy link
Author

jwkuo commented Oct 30, 2023

Noted. I've reached out to Browserless with this issue.

@OrKoN
Copy link
Collaborator

OrKoN commented Oct 30, 2023

Some context: there were a lot of changes in auto-attach in Chrome, in particular, many issues around tab target has been fixed . Starting from 21.4.0 Puppeteer relies on the new target type: #11099 We generally don't guarantee compatibility of new Puppeteer versions with older browser binaries and we recommend using the version that is bundled with a specific Puppeteer release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants