question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Navigation failed because browser has disconnected error on AWS Lambda

See original GitHub issue

I’m using puppeteer-core on AWS Lambda with chromium builds taken here.

I create a new browser instance per lambda invocation, like this:

    const browser = await puppeteer.launch({
        args: [
            '--disable-gpu',
            '--disable-dev-shm-usage',
            '--disable-setuid-sandbox',
            '--no-first-run',
            '--no-sandbox',
            '--no-zygote',
            '--single-process',
        ],
        executablePath: './bin/headless-chromium',
        userDataDir: '/tmp/puppeteer_data'
    });

Everything works fine except when I have many, many invocations of this lambda. It’s hard to tell how many but I’d say ~ 500 invocations near the same time.

error: Error: Navigation failed because browser has disconnected!
    at CDPSession.LifecycleWatcher._eventListeners.helper.addEventListener (/var/task/node_modules/puppeteer-core/lib/FrameManager.js:1181:107)
    at emitNone (events.js:106:13)
    at CDPSession.emit (events.js:208:7)
    at CDPSession._onClosed (/var/task/node_modules/puppeteer-core/lib/Connection.js:231:10)
    at Connection._onClose (/var/task/node_modules/puppeteer-core/lib/Connection.js:121:15)
    at WebSocketTransport._ws.addEventListener.event (/var/task/node_modules/puppeteer-core/lib/WebSocketTransport.js:45:22)
    at WebSocket.onClose (/var/task/node_modules/puppeteer-core/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 (/var/task/node_modules/puppeteer-core/node_modules/ws/lib/websocket.js:180:10)
    -- ASYNC --
    at Frame.<anonymous> (/var/task/node_modules/puppeteer-core/lib/helper.js:144:27)
    at Page.goto (/var/task/node_modules/puppeteer-core/lib/Page.js:624:49)
    at Page.<anonymous> (/var/task/node_modules/puppeteer-core/lib/helper.js:145:23)
    at getHTML (/var/task/src/details/details.js:100:16)
    at <anonymous>
    at process._tickDomainCallback (internal/process/next_tick.js:228:7)

This error keeps going on for each event that triggers the lambda, until the lambda container is gone.

  • Puppeteer version: 1.11.0
  • Platform / OS version: AWS Lambda
  • URLs (if applicable):
  • Node.js version: 8.10

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:8
  • Comments:22 (1 by maintainers)

github_iconTop GitHub Comments

17reactions
aslushnikovcommented, Mar 4, 2019

Looks like a dupe of #2463

8reactions
toolekscommented, Apr 5, 2019

Had this issue with both 1.11 and 1.12 (chrome 72 and 73). I can confirm that one of flags at: https://github.com/alixaxel/chrome-aws-lambda/blob/master/source/index.js solved this issue for me. I’ve used them all so haven’t isolated which one.

--single-process flag solved the issue for me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: Navigation failed because browser has disconnected ...
The Navigation failed because browser has disconnected error usually means that the node scripts that launched Puppeteer ends without ...
Read more >
Navigation failed because browser has disconnected!
[1] Navigation failed because browser has disconnected! (An internal WebSocket error occurred. Please see the innerException, if present, for ...
Read more >
error: navigation failed because browser has disconnected!
The Navigation failed because browser has disconnected error usually means that the node scripts that launched Puppeteer ends without waiting for the Puppeteer...
Read more >
[BUG] Navigation failed because browser has disconnected ...
Hi Just want to share an issue I found that bothered me for a while, which might have something to do with the...
Read more >
Troubleshooting a failed canary - Amazon CloudWatch
This error appears if there are some network requests after the page or browser is closed. You might have forgotten to wait for...
Read more >

github_iconTop Related Medium Post

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