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] Connection not closed correctly in v10.1.0 #7407

Closed
DRoet opened this issue Jul 6, 2021 · 8 comments
Closed

[bug] Connection not closed correctly in v10.1.0 #7407

DRoet opened this issue Jul 6, 2021 · 8 comments

Comments

@DRoet
Copy link

DRoet commented Jul 6, 2021

Steps to reproduce

Tell us about your environment:

  • Puppeteer version: 10.1.0
  • Platform / OS version: Docker/Linux
  • URLs (if applicable):
  • Node.js version: 16.3.0

What steps will reproduce the problem?
When updating from 10.0.0 -> 10.1.0 I suddenly get an error when connecting to a remote chrome instance using browser.connect(). The remote chrome instance I am using is a simple browserless/chrome docker image running on a dedicated port

Please include code that reproduces the issue.

  1. I am using the following code to connect to a remote chrome instance and create a PDF
   const browser = await puppeteer.connect({
      browserWSEndpoint: 'http://chromeinstance:port/',
   })
   const page = await browser.newPage()
   await page.setContent(html, { waitUntil: 'networkidle2' })
   await page.pdf({ format: format, landscape: landscape })
   await browser.disconnect()

What is the expected result?
Connection closes correctly, no error is being shown. This works fine in v10.0.0

What happens instead?
following error is being thrown:

/opt/app/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Connection.js:217
            this._callbacks.set(id, { resolve, reject, error: new Error(), method });
                                                              ^

Error: Protocol error (IO.close): Target closed.
    at /opt/app/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Connection.js:217:63
    at new Promise (<anonymous>)
    at CDPSession.send (/opt/app/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Connection.js:216:16)
    at Readable.read [as _read] (/opt/app/node_modules/puppeteer-core/lib/cjs/puppeteer/common/helper.js:281:30)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
@4geru
Copy link

4geru commented Jul 8, 2021

our project caused same error which version up from 10.0.0 to 10.1.0.

@nadaDeversity
Copy link

@DRoet Do you have any updates on this? I get the same error on await browser.close() (did not use puppeteer.connect but puppeteer.launch)

@DRoet
Copy link
Author

DRoet commented Jul 29, 2021

Nope, best to stay on 10.0.0 for now, there is a PR up trying to fix the issue #7414 but there isn't much traction yet.

@simonhaenisch
Copy link

simonhaenisch commented Aug 30, 2021

I'm probably running into this issue with one of my project's pipelines, but only on Node 14 and 16 on Windows.

@jschfflr
Copy link
Contributor

Unfortunately, I can not reproduce this problem on my machine. Could you maybe share a reproduction?

@nadaDeversity
Copy link

@jschfflr

I used chrome-aws-lambda with puppeteer-core package and the error I mentioned occurred when I was running some load tests - basically just hitting the lambda and generating some PDFs with 3 workers in parallel, about 50-100 times each.

The error occurrs when browser.close() is called - Error: Protocol error (IO.close): Target closed

I tried downgrading both the puppeteer package as well as the nodejs, but the error kept happening.

"chrome-aws-lambda": "^10.1.0",
"puppeteer-core": "^10.2.0"

Lambda code:

const chromium = require('chrome-aws-lambda') 

try {
  browser = await chromium.puppeteer.launch({
      args: chromium.args,
      defaultViewport: chromium.defaultViewport,
      executablePath: await chromium.executablePath,
      headless: chromium.headless,
      ignoreHTTPSErrors: true
  })
  await page.goto('<some target>', { waitUntil: 'networkidle2' })
  let pdf = await page.pdf({ format: 'A4', landscape: true })
...
} catch(err) {
...
} finally {
  if (browser !== null) {
       await browser.close()
   }
}

@SimenB
Copy link

SimenB commented Oct 28, 2021

Getting this after upgrading from node 14 to node 16. Doesn't happen all the time, but often enough...

Extra annoying that there is some unhandled rejection somewhere, so our server just crashes rather than returning at least a 500 error

@jschfflr
Copy link
Contributor

This should have been fixed in #7728.
I'll cut a new Puppeteer version next week :)

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

No branches or pull requests

6 participants