cypress-io / xvfb

Easily start and stop an X Virtual Frame Buffer from your node apps

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error with latest version of puppeteer

jibon57 opened this issue · comments

Hello,

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

const puppeteer = require('puppeteer');
const Xvfb      = require('@cypress/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.start()
  const browser = await puppeteer.launch(options);
  const page = await browser.newPage();
  await page.goto('https://news.ycombinator.com', {waitUntil: 'networkidle2'});

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

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?