Protocol error - Target closed: puppeteer stopped working.

See original GitHub issue

Steps to reproduce

Tell us about your environment:

  • Puppeteer version: 10.1.0
  • Platform / OS version: Arch Linux x86_64 5.13.6-arch1-1
  • URLs (if applicable):
  • Node.js version: v16.6.0

What steps will reproduce the problem?

Please include code that reproduces the issue.

  1. mkdir -p /tmp/test-p && cd /tmp/test-p
  2. yarn init (default for all options)
  3. yarn add puppeteer
  4. vim ./index.js then copy/paste/save the first code example in the readme:
const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  await page.goto('https://example.com');
  await page.screenshot({ path: 'example.png' });

  await browser.close();
})();
  1. node ./index.js

What is the expected result? No error and a screenshot.

What happens instead?

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

Error: Protocol error (Page.navigate): Target closed.
    at /tmp/test-p/node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:217:63
    at new Promise (<anonymous>)
    at CDPSession.send (/tmp/test-p/node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:216:16)
    at navigate (/tmp/test-p/node_modules/puppeteer/lib/cjs/puppeteer/common/FrameManager.js:108:47)
    at FrameManager.navigateFrame (/tmp/test-p/node_modules/puppeteer/lib/cjs/puppeteer/common/FrameManager.js:91:13)
    at Frame.goto (/tmp/test-p/node_modules/puppeteer/lib/cjs/puppeteer/common/FrameManager.js:416:41)
    at Page.goto (/tmp/test-p/node_modules/puppeteer/lib/cjs/puppeteer/common/Page.js:1133:53)
    at /tmp/test-p/index.js:6:14
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

Additional information I’ve been using puppeteer for months without any issue. Earlier, I tried to run one of my scripts but I got the error above. I tried to narrow the problem and found out that it still happens even with a fresh install and a simple code.

Whats the root cause of this error ? Am i doing something wrong ? Needless to say that i didn’t find any answer in google/SO/etc.

Thanks in advance!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:16
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
marcelariecommented, Feb 1, 2022

I’m using puppeteer@13.0.1 with no problems now.

5reactions
MunyuShizumicommented, Sep 15, 2021

Exact same issue here with Puppeteer v10.2.0, v9.1.1, v8.0.0 & Node v16.9.1, v14.17.4. Downgrading to Puppeteer v7.1.0 resolves the issue, so it’s something introduced between v7.1.0 and v8.0.0.

Technically, it’s not a Page.goto() issue, ChromeLauncher.launch() will also fail on its own half a second later:

Error: Protocol error (Target.setDiscoverTargets): Target closed.
    at /home/shizumi/puppeteer-test/node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:71:63
    at new Promise (<anonymous>)
    at Connection.send (/home/shizumi/puppeteer-test/node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:70:16)
    at Function.create (/home/shizumi/puppeteer-test/node_modules/puppeteer/lib/cjs/puppeteer/common/Browser.js:117:26)
    at ChromeLauncher.launch (/home/shizumi/puppeteer-test/node_modules/puppeteer/lib/cjs/puppeteer/node/Launcher.js:109:56)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async /home/shizumi/puppeteer-test/example.js:4:18

All Chromium dependencies installed, using Brave as a daily browser without issues.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Puppeteer - Protocol error (Page.navigate): Target closed
The Target closed exception is thrown when you are trying to run a function, but the target (tab) was already closed. Similar error...
Read more >
Error - Target closed
Obvious possible cause: the browser, context or tab is being closed at the wrong time in the script. Not-so-obvious possible cause: promises are...
Read more >
puppeteer-chat/Lobby
{ Error: Protocol error (Runtime.callFunctionOn): Target closed. at Promise (/src/app/node_modules/puppeteer/lib/Connection.js:183:56)
Read more >
How to use Puppeteer inside a Docker container
and i get this error "Protocol error (Target. ... https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md\n". 1 like Like
Read more >
Puppeteer - Protocol error (Page.navigate): Target closed
Puppeteer - Protocol error (Page.navigate): Target closed. Answer a question As you can see with the sample code below, I'm using Puppeteer ......
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