最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Puppeteer cluster example throwing Error: Unable to get browser page - Stack Overflow

programmeradmin2浏览0评论

I'm using this example in the puppeteer-cluster docs

I am running this on node v10.15.3 I have attempted passing the headless property and slowMo to puppeteer options.

I would expect the code to log out and create a Screenshot of the page however, what happens is several chrome instances boot up which do not load any of the pages then the console hangs and errors with:

(node:30826) UnhandledPromiseRejectionWarning: Error: Unable to get browser page
    at Worker.<anonymous> (/Users/Starlord/Code/oppose/node_modules/puppeteer-cluster/dist/Worker.js:43:31)
    at Generator.next (<anonymous>)
    at fulfilled (/Users/Starlord/Code/oppose/node_modules/puppeteer-cluster/dist/Worker.js:4:58)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:30826) 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: 21)
(node:30826) [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.
(node:30826) UnhandledPromiseRejectionWarning: Error: Unable to get browser page
    at Worker.<anonymous> (/Users/Starlord/Code/oppose/node_modules/puppeteer-cluster/dist/Worker.js:43:31)
    at Generator.next (<anonymous>)
    at fulfilled (/Users/Starlord/Code/oppose/node_modules/puppeteer-cluster/dist/Worker.js:4:58)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:30826) 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: 22)
^Cinternal/process/per_thread.js:198
      throw errnoException(err, 'kill');
      ^

Error: kill ESRCH
    at process.kill (internal/process/per_thread.js:198:13)
    at process.killChrome (/Users/Starlord/Code/oppose/node_modules/puppeteer/lib/Launcher.js:110:17)
    at process.emit (events.js:189:13)

I'm using this example in the puppeteer-cluster docs

I am running this on node v10.15.3 I have attempted passing the headless property and slowMo to puppeteer options.

I would expect the code to log out and create a Screenshot of the page however, what happens is several chrome instances boot up which do not load any of the pages then the console hangs and errors with:

(node:30826) UnhandledPromiseRejectionWarning: Error: Unable to get browser page
    at Worker.<anonymous> (/Users/Starlord/Code/oppose/node_modules/puppeteer-cluster/dist/Worker.js:43:31)
    at Generator.next (<anonymous>)
    at fulfilled (/Users/Starlord/Code/oppose/node_modules/puppeteer-cluster/dist/Worker.js:4:58)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:30826) 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: 21)
(node:30826) [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.
(node:30826) UnhandledPromiseRejectionWarning: Error: Unable to get browser page
    at Worker.<anonymous> (/Users/Starlord/Code/oppose/node_modules/puppeteer-cluster/dist/Worker.js:43:31)
    at Generator.next (<anonymous>)
    at fulfilled (/Users/Starlord/Code/oppose/node_modules/puppeteer-cluster/dist/Worker.js:4:58)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:30826) 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: 22)
^Cinternal/process/per_thread.js:198
      throw errnoException(err, 'kill');
      ^

Error: kill ESRCH
    at process.kill (internal/process/per_thread.js:198:13)
    at process.killChrome (/Users/Starlord/Code/oppose/node_modules/puppeteer/lib/Launcher.js:110:17)
    at process.emit (events.js:189:13)
Share Improve this question asked May 18, 2019 at 7:38 MoshieMoshie 951 silver badge12 bronze badges 2
  • Author of the library here. This happens when the opening of a new page fails several times. Most of the time, there are some other issues like memory/disk/CPU restrictions that might make the browser crash. Can you add the debugging logs? Then I can exactly tell you why the error happens. – Thomas Dondorf Commented May 18, 2019 at 7:59
  • Thanks for getting back so quickly! pastebin./9d3JB3aA – Moshie Commented May 18, 2019 at 8:37
Add a ment  | 

2 Answers 2

Reset to default 7

This error happens when the library is unable to create a new browser page. The error is thrown here after several tries of opening a new context/page/browser (depending on your settings).

Debugging log

To get more information on what causes the error, you can check the debugging log. This starts the application in debugging mode and will log more information. To enter debugging mode you need to start the application with the environment variable DEBUG='puppeteer-cluster:*':

# Linux
DEBUG='puppeteer-cluster:*' node application.js
# Windows Powershell
$env:DEBUG='puppeteer-cluster:*';node application.js

Problem

In your case the debug logs shows (copied from your ment above):

puppeteer-cluster: Worker Error getting browser page (try: 9), message: this.browser.createIncognitoBrowserContext is not a function +660ms

This means, there is no createIncognitoBrowserContext that the library can use to create a new context. As you already confirmed, this is the case, because you are using an old puppeteer installation. To use the setting { concurrency: Cluster.CONCURRENCY_CONTEXT }, you have to be using at least version 1.5.0 as that was when contexts were introduced.

Fix

To fix the problem, update your puppeteer installation:

npm install puppeteer@latest

The problem was that I was using puppeteer-pool before puppeteer-cluster which uses an older version of puppeteer.

I removed puppeteer-pool and installed puppeteer and it works as expected

发布评论

评论列表(0)

  1. 暂无评论