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]: Puppeteer throwing error when running non-headless #7902

Closed
jackmparker opened this issue Jan 14, 2022 · 16 comments
Closed

[Bug]: Puppeteer throwing error when running non-headless #7902

jackmparker opened this issue Jan 14, 2022 · 16 comments

Comments

@jackmparker
Copy link

Bug description

I'm using puppeteer to visit a webpage and view all the network requests that fire but I've found that an error is thrown when running in non-headless mode and I can't figure out the cause of this error. No amount of Googling has turned up an answer so far. Here's the error:

/Users/myusername/dev/puppeteer-test/node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:226
                error: new Errors_js_1.ProtocolError(),
                       ^

ProtocolError: Protocol error (Page.createIsolatedWorld): No frame for given id found
    at /Users/myusername/dev/puppeteer-test/node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:226:24
    at new Promise (<anonymous>)
    at CDPSession.send (/Users/myusername/dev/puppeteer-test/node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:222:16)
    at /Users/myusername/dev/puppeteer-test/node_modules/puppeteer/lib/cjs/puppeteer/common/FrameManager.js:290:37
    at Array.map (<anonymous>)
    at FrameManager._ensureIsolatedWorld (/Users/myusername/dev/puppeteer-test/node_modules/puppeteer/lib/cjs/puppeteer/common/FrameManager.js:290:14)
    at async Promise.all (index 1)
    at async FrameManager.initialize (/Users/myusername/dev/puppeteer-test/node_modules/puppeteer/lib/cjs/puppeteer/common/FrameManager.js:102:13)
    at async FrameManager._onAttachedToTarget (/Users/myusername/dev/puppeteer-test/node_modules/puppeteer/lib/cjs/puppeteer/common/FrameManager.js:185:9) {
  originalMessage: 'No frame for given id found'
}

This is a dumbed down sample of my project code that throws this error:

const puppeteer = require('puppeteer');
const url = 'https://jpstyle.us/';

(async () => {
  const browser = await puppeteer.launch({
    executablePath: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
    headless: false,
    slowMo: 250
  });

  const page = await browser.newPage();

  let foundRequest = false;
  let request;

  await page.setRequestInterception(true);

  page.on('request', (interceptedRequest) => {
    if (interceptedRequest.url().includes('googleads.g.doubleclick.net/pagead/ads')) {
      foundRequest = true;
      request = interceptedRequest;
    }

    interceptedRequest.continue();
  });

  await page.goto(url, { waitUntil: 'networkidle0' });
  await browser.close();

  console.log(`Google Ads Remarketing was ${foundRequest ? 'found' : 'not found'}`);

  if (foundRequest) {
    console.log(request);
  }
})();

If you change the value of headless to true in the launch options object that is passed when launching puppeteer then this error goes away and everything runs as expected. For the purposes of this project I can't run in headless mode, so I need to figure out why this error is happening.

Any help or direction is appreciated!

Puppeteer version

13.0.1

Node.js version

v16.13.1

npm version

8.1.2

What operating system are you seeing the problem on?

macOS

Relevant log output

No response

@brandoshizzle
Copy link

I'm also having this issue, with MacOS in Node v15.12.0. I'd love to see a solution as I have a project that can't be headless!

@jozsi
Copy link

jozsi commented Jan 19, 2022

FYI: there is a (yet unmerged) pull request for it: #7848

Until then, rolling back to v12.0.1 works for me.

@markon1
Copy link

markon1 commented Jan 20, 2022

Same error with v12.0.1, macOS Catalina 10.15.7, running with headless: false.
I have a script which ran fine for months, and now it throws this error once in maybe 40-50 runs, no rules.

Updated to v13.0.1 just now, but as I can see it hasn't been fixed in it yet, based on OP's comment.

@lgh06
Copy link

lgh06 commented Jan 26, 2022

same here, windows, non-headless, v13, start several puppeteer instances at a time, some times this error exists and let my whole Node.js project exit.

@pedro-vo
Copy link

Same here, Windows 10, non-headless, puppeteer v. 13.1.3

UnhandledPromiseRejectionWarning: ProtocolError: Protocol error (Page.createIsolatedWorld): No frame for given id found

while calling goto()

@visualsitemaps
Copy link

visualsitemaps commented Feb 2, 2022

Same issue here with Chrome + Puppeteer 11/12/13 😬

@billycalladine
Copy link

Same issue here when running tests in non-headless in Chrome with Puppeteer v12.0.1, node v16.13.0

@andrevlima
Copy link

Same here, several days, no solution found

@Eden4897
Copy link

Same problem here. Also, everytime this happens, it creates 3 zombie chomium processes thats eating up my cpu and ram

@Eden4897
Copy link

Eden4897 commented Feb 19, 2022

I have currently "fixed" this problem by adding a global error catcher:

process.on('uncaughtException', function (err) {
  console.log('Caught exception: ' + err);
});

Edit: Use this so that it ignores this specific error only

process.on("uncaughtException", function (err) {
  if (
    err
      .toString()
      .startsWith("Error: Execution context is not available in detached frame")
  )
    return;
  console.error("Caught exception: " + err);
});

@pankhiprasher
Copy link

Hey I am having difficulty running puppeteer functions . I keep getting this error -
(node:13460) UnhandledPromiseRejectionWarning: Error: Failed to launch the browser process!
/node_modules/puppeteer/.local-chromium/linux-970485/chrome-linux/chrome: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory

TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md

at onClose (/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:237:20)
at Interface.helper_js_1.helper.addEventListener (/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:227:68)
at Interface.emit (events.js:203:15)
at Interface.close (readline.js:397:8)
at Socket.onend (readline.js:173:10)
at Socket.emit (events.js:203:15)
at endReadableNT (_stream_readable.js:1145:12)
at process._tickCallback (internal/process/next_tick.js:63:19)

(node:13460) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:13460) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I have tried installing all dependencies and all 1000 resolutions to disable sandbox and what not but no luck , i see on this post you guys have reached a step or more ahead of me so i will be really glad if you can help me out with this error resolution.

@lgh06
Copy link

lgh06 commented Mar 16, 2022

@pankhiprasher your questions are not related to this issue mentioned above.
seems like your linux missing some dependencies, see https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md#chrome-headless-doesnt-launch-on-unix and open inner details arrow.

@pankhiprasher
Copy link

@lgh06 its still giving in the same error even after i installed all libraries and dependencis

@lgh06
Copy link

lgh06 commented Mar 18, 2022

@pankhiprasher I am on a Ubuntu Server 20.04 LTS and those official troubleshooting dependencies worked for me.
my scripts are here:
https://github.com/lgh06/web-page-monitor/tree/main/packages/vendor-scripts-n-configs/pptr
and from the error log you pasted, it shows missing libnss3.so.
ensure that libnss3.so and all other deps exist, then clear all node_modules and clear npm cache and maybe a reboot and install puppeteer then start.
also, ensure you have enough permissions to execute both those dependencies and pptr. (chmod or sudo or su root)

@stale
Copy link

stale bot commented Jun 23, 2022

We're marking this issue as unconfirmed because it has not had recent activity and we weren't able to confirm it yet. It will be closed if no further activity occurs within the next 30 days.

@stale stale bot added the unconfirmed label Jun 23, 2022
@stale
Copy link

stale bot commented Jul 25, 2022

We are closing this issue. If the issue still persists in the latest version of Puppeteer, please reopen the issue and update the description. We will try our best to accomodate it!

@stale stale bot closed this as completed Jul 25, 2022
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

10 participants