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

Error with latest version of puppeteer #9

Closed
jibon57 opened this issue Mar 28, 2020 · 7 comments
Closed

Error with latest version of puppeteer #9

jibon57 opened this issue Mar 28, 2020 · 7 comments

Comments

@jibon57
Copy link

jibon57 commented Mar 28, 2020

Hello,

Thanks for your library. I am using it with puppeteer like this:

const puppeteer = require('puppeteer');
const Xvfb      = require('xvfb');

var xvfb        = new Xvfb({silent: true});
var options     = {
  headless: false,
  args: [
    '--disable-infobars',
    '--no-sandbox',    
    '--shm-size=1gb',
    '--disable-dev-shm-usage',
  ],
}


async function main(){
  xvfb.startSync()
  const browser = await puppeteer.launch(options);
  const page = await browser.newPage();
  await page.goto('https://news.ycombinator.com', {waitUntil: 'networkidle2'});

  await browser.close();
  xvfb.stopSync()
}

main()

But I am getting errors like this:

(node:25099) UnhandledPromiseRejectionWarning: Error: Navigation failed because browser has disconnected!
    at CDPSession.LifecycleWatcher._eventListeners.helper.addEventListener (/root/bbb-recorder/node_modules/puppeteer/lib/LifecycleWatcher.js:46:107)
    at emitNone (events.js:106:13)
    at CDPSession.emit (events.js:208:7)
    at CDPSession._onClosed (/root/bbb-recorder/node_modules/puppeteer/lib/Connection.js:215:10)
    at Connection._onClose (/root/bbb-recorder/node_modules/puppeteer/lib/Connection.js:138:15)
    at WebSocketTransport._ws.addEventListener.event (/root/bbb-recorder/node_modules/puppeteer/lib/WebSocketTransport.js:48:22)
    at WebSocket.onClose (/root/bbb-recorder/node_modules/puppeteer/node_modules/ws/lib/event-target.js:124:16)
    at emitTwo (events.js:126:13)
    at WebSocket.emit (events.js:214:7)
    at WebSocket.emitClose (/root/bbb-recorder/node_modules/puppeteer/node_modules/ws/lib/websocket.js:191:10)
  -- ASYNC --
    at Frame.<anonymous> (/root/bbb-recorder/node_modules/puppeteer/lib/helper.js:111:15)
    at Page.goto (/root/bbb-recorder/node_modules/puppeteer/lib/Page.js:672:49)
    at Page.<anonymous> (/root/bbb-recorder/node_modules/puppeteer/lib/helper.js:112:23)
    at main (/root/bbb-recorder/test.js:25:14)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7)
(node:25099) 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:25099) [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.

Any suggestion please?

@Rob--W
Copy link
Owner

Rob--W commented Mar 28, 2020

Can't reproduce with node 13.11.0, xvfb 0.3.0, puppeteer 2.1.1, Chromium 80 on Linux.

@jibon57
Copy link
Author

jibon57 commented Mar 28, 2020

Thanks for your quick response my node version v8.17.0.

  "dependencies": {
    "puppeteer": "^2.1.1",
    "ws": "^7.2.3",
    "xvfb": "^0.3.0"
  }

I am testing from Ubuntu 16.04 LTS

@Rob--W
Copy link
Owner

Rob--W commented Mar 28, 2020

Are you able to successfully run other GUI programs instead of Chromium through Puppeteer?

If yes, then it's likely not an issue with xvfb.

Why are you using headless: false,? With headless: true, you can run Chromium without a display. Certain features such as extensions won't be available, but if you don't need it you may as well run in headless mode.

@jibon57
Copy link
Author

jibon57 commented Mar 28, 2020

Thanks for reply @Rob--W . Actually I am using screen sharing feature of Chromium to live record. It's working with older version of Puppeteer but new version having that problem. If I don't use xvfb then it's working fine

@jibon57
Copy link
Author

jibon57 commented Mar 29, 2020

@Rob--W if I try like this way in terminal then it's working:

xvfb-run -a --server-args="-screen 0 1280x800x24 -ac -nolisten tcp -dpi 96 +extension RANDR" node test.js

How can I do that using your module? I tried like this:

var xvfb        = new Xvfb({
    silent: true,
    xvfb_args: "-screen 0 1280x800x24 -ac -nolisten tcp -dpi 96 +extension RANDR"
});

But not working. Sorry, I ain't expert on this.

@Rob--W
Copy link
Owner

Rob--W commented Mar 29, 2020

xvfb_args should be an array of individual arguments.

Try

var xvfb        = new Xvfb({
    silent: true,
    xvfb_args: ["-screen", "0", "1280x800x24", "-ac", "-nolisten", "tcp", "-dpi", "96", "+extension", "RANDR"],
});

@jibon57
Copy link
Author

jibon57 commented Mar 30, 2020

@Rob--W thank you so much!! It's working now 💯

@jibon57 jibon57 closed this as completed Mar 30, 2020
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

2 participants