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

Navigation failed because browser has disconnected #3

Closed
ramesh82 opened this issue Oct 31, 2018 · 23 comments
Closed

Navigation failed because browser has disconnected #3

ramesh82 opened this issue Oct 31, 2018 · 23 comments

Comments

@ramesh82
Copy link

Hello there, I am getting the below error when executing your sample code.
{
"errorMessage": "Navigation failed because browser has disconnected!",
"errorType": "Error",
"stackTrace": [
"Connection.NavigatorWatcher._eventListeners.helper.addEventListener (/var/task/node_modules/puppeteer-core/lib/FrameManager.js:1146:117)",
"emitNone (events.js:111:20)",
"Connection.emit (events.js:208:7)",
"Connection._onClose (/var/task/node_modules/puppeteer-core/lib/Connection.js:123:10)",
"WebSocketTransport._ws.addEventListener.event (/var/task/node_modules/puppeteer-core/lib/WebSocketTransport.js:45:22)",
"WebSocket.onClose (/var/task/node_modules/ws/lib/event-target.js:124:16)",
"emitTwo (events.js:126:13)",
"WebSocket.emit (events.js:214:7)",
"WebSocket.emitClose (/var/task/node_modules/ws/lib/websocket.js:172:10)",
"Socket.socketOnClose (/var/task/node_modules/ws/lib/websocket.js:781:15)",
" -- ASYNC --",
"Frame. (/var/task/node_modules/puppeteer-core/lib/helper.js:144:27)",
"Page.goto (/var/task/node_modules/puppeteer-core/lib/Page.js:579:49)",
"Page. (/var/task/node_modules/puppeteer-core/lib/helper.js:145:23)",
"exports.handler (/var/task/index.js:17:20)",
"",
"process._tickDomainCallback (internal/process/next_tick.js:228:7)"
]
}

@jayatudn
Copy link

jayatudn commented Nov 9, 2018

Yes,I also met the same issue.Any idea?

@simonklb
Copy link

I'm seeing this as well, only on certain websites.

Running without the --single-process flag does solve it for me locally, but obviously won't work in AWS Lambda.

One thing that might be of interest is that running with --single-process does work locally if you also add libEGL.so and libGLESv2.so into the mix (in my case just added them to /tmp/swiftshader). But still no luck on AWS Lambda due to missing X display. You can simulate this locally by unsetting the DISPLAY environment variable.

Any help or insights would be much appreciated!

@simonklb
Copy link

Some examples is perhaps a good idea.

Sites that causes the error:
https://docker.com
https://gitlab.com
https://apple.com
https://adobe.com
https://redhat.com

Sites that does not cause the error:
https://google.com
https://github.com
https://twitter.com

@simonklb
Copy link

I believe I've found a solution to the problem. Use the --disable-software-rasterizer flag. No extra libraries required.

Hope it works for your use-cases as well!

@jayatudn
Copy link

Thanks for your help.
It is still not work that I use the --disable-software-rasterizer flag.
But I use the --disable-gpu flag, it works!

@ramesh82
Copy link
Author

How do we change/increase the default page timeout which is 30 seconds? We could use page.setDefaultNavigationTimeout() but do we have any timeouts that we can set in the browser rather setting it within the page? Please advise. thanks in advance.

@ramesh82
Copy link
Author

Also I am experiencing performance issues with this chrome. Does anyone experience the same? @serverless-chrome/lambda works faster but I am having issues packaging multiple lambda functions in serverless.

@lg
Copy link

lg commented Nov 18, 2018

Just want to mention that i had a similar problem with https://united.com (and the others that @simonklb mentioned), but using both --disable-software-rasterizer and --disable-gpu flags fixed Chromium from crashing. @alixaxel, consider adding these to the default args array.

@alixaxel
Copy link
Owner

@lg Thanks for reporting this, apparently puppeteer silently removed --disable-gpu from the list of their default arguments on version 1.5.0, I've added those flags as default in the latest version as well as a few extra to ensure future-proof stability.

@gyss
Copy link

gyss commented Feb 24, 2020

I had the same issue. After adding those flags and increasing the lambda memory the problem was still there. After some research I discovered that the error "Navigation failed because browser has disconnected!" was triggered only if the firebase database connection was open. Solution, close the connection before using puppeteer. Hope this helps somebody

@gsouf
Copy link

gsouf commented Mar 6, 2020

Here, none of --disable-software-rasterizer and --disable-gpu work, still crashing

Normal puppeter does not crah, even with single-process flag

@gsouf
Copy link

gsouf commented Mar 6, 2020

Just for the record, that's the error generated by chrome:

[0306/164635.350450:FATAL:service.cc(56)] Check failed: !base::SystemMonitor::Get(). 
#0 0x55d403e56939 <unknown>
#1 0x55d403dc8443 <unknown>
#2 0x55d403dd94d5 <unknown>
#3 0x55d4030ce9b1 <unknown>
#4 0x55d4030d0fe6 <unknown>
#5 0x55d403d84e26 <unknown>
#6 0x55d403d85c54 <unknown>
#7 0x55d40558492c <unknown>
#8 0x55d403e06a1b <unknown>
#9 0x55d403e177ce <unknown>
#10 0x55d403e17561 <unknown>
#11 0x55d403ddd9ca <unknown>
#12 0x55d403e18059 <unknown>
#13 0x55d403df45e2 <unknown>
#14 0x55d403e2c037 <unknown>
#15 0x55d403e65f1e <unknown>
#16 0x7f1ab0c7f6db start_thread
#17 0x7f1aaf80888f clone
Task trace:
#0 0x55d40558445a <unknown>
#1 0x55d4046d2c85 <unknown>
#2 0x55d4046e9921 <unknown>
#3 0x55d4055821b8 <unknown>
#4 0x55d403d833f9 <unknown>
IPC message handler context: 0x1D6C7CD1

Received signal 6
#0 0x55d403e56939 <unknown>
#1 0x55d403dc8443 <unknown>
#2 0x55d403e56481 <unknown>
#3 0x7f1ab0c8a890 <unknown>
#4 0x7f1aaf725e97 gsignal
#5 0x7f1aaf727801 abort
#6 0x55d403e55285 <unknown>
#7 0x55d403dd9974 <unknown>
#8 0x55d4030ce9b1 <unknown>
#9 0x55d4030d0fe6 <unknown>
#10 0x55d403d84e26 <unknown>
#11 0x55d403d85c54 <unknown>
#12 0x55d40558492c <unknown>
#13 0x55d403e06a1b <unknown>
#14 0x55d403e177ce <unknown>
#15 0x55d403e17561 <unknown>
#16 0x55d403ddd9ca <unknown>
#17 0x55d403e18059 <unknown>
#18 0x55d403df45e2 <unknown>
#19 0x55d403e2c037 <unknown>
#20 0x55d403e65f1e <unknown>
#21 0x7f1ab0c7f6db start_thread
#22 0x7f1aaf80888f clone
  r8: 0000000000000000  r9: 00007f1a969d52f0 r10: 0000000000000008 r11: 0000000000000246
 r12: 00007f1a969d65d8 r13: 00007f1a969d5590 r14: 00007f1a969d65e0 r15: aaaaaaaaaaaaaaaa
  di: 0000000000000002  si: 00007f1a969d52f0  bp: 00007f1a969d5540  bx: 00007f1a969d55b4
  dx: 0000000000000000  ax: 0000000000000000  cx: 00007f1aaf725e97  sp: 00007f1a969d52f0
  ip: 00007f1aaf725e97 efl: 0000000000000246 cgf: 002b000000000033 erf: 0000000000000004
 trp: 000000000000000e msk: 0000000000000000 cr2: 00007f0c7f918008
[end of stack trace]
Calling _exit(1). Core file will not be generated.

@castus
Copy link

castus commented Mar 7, 2020

I had the same issue. Removing all options from goto() function works on AWS Lambda.
Previously:

await page.goto(url, {
    waitUntil: ["load", "networkidle2"]
});

Currently:

await page.goto(url);

Hope this helps somebody.

@gsouf
Copy link

gsouf commented Mar 9, 2020

@castus that's because you're not testing the right thing. The browser crashes after the navigation has occurred. By removing waitUntil you use the default that is load.

Try to wait a little bit more before performing any other action on the page and that will fail again.

@gsouf
Copy link

gsouf commented Mar 9, 2020

I was wrong to assert that this issue only occurs with this build of chrome.

I double checked and it also produces normal puppeteer. Opened a ticket on puppeteer directly puppeteer/puppeteer#5487

@gsouf
Copy link

gsouf commented Mar 10, 2020

Reading here https://www.chromium.org/developers/design-documents/process-models#TOC-Single-process
It says it should be use for development purposes only.

Also I suspect the crash to happen because a component on this website crashes, getting the only one process allocated to the browser to crash as well.

@alixaxel could you please inform us why the single-process flag is important for aws lambda/GCF? It seems it won't fit all situations.

Edit: Please, note that I opened a ticket on chromium support https://bugs.chromium.org/p/chromium/issues/detail?id=1060099#c6

@alexfernandez
Copy link

@gsouf chrome-aws-lambda doesn't work for me on Lambda without --single-process, it seems it is important 🤔

@gsouf
Copy link

gsouf commented Apr 20, 2020

@alexfernandez I run on google cloud function and it runs well without single process. But it's slower.

@alixaxel
Copy link
Owner

alixaxel commented May 8, 2020

Solution posted here.

@gsouf As @alexfernandez mentioned, without --single-process Lambda won't work.
Lambda being single-threaded, there's no workaround around that.

@ali-habibzadeh
Copy link

ali-habibzadeh commented May 12, 2020

Solution posted here.

@gsouf As @alexfernandez mentioned, without --single-process Lambda won't work.
Lambda being single-threaded, there's no workaround around that.

I tried adding --disable-features=AudioServiceOutOfProcess to args but still getting lot of random Navigation failed because browser has disconnected!. I am using version 3.0.4

@alixaxel
Copy link
Owner

@ali-habibzadeh

With 3.0.4 --disable-features=AudioServiceOutOfProcess is included by default.

Could you share more details / repro of your problem in a new issue?

@ali-habibzadeh
Copy link

@ali-habibzadeh

With 3.0.4 --disable-features=AudioServiceOutOfProcess is included by default.

Could you share more details / repro of your problem in a new issue?

Unfortunately I have moved on from it, it's ok just not super stable for my use case. I moved chrome to docker on Fargate service (ECS cluster) and now using Puppeteer code on lambda to drive. Getting no errors, no navigation failed etc. Perhaps chrome inside lambda is a step too much for lambda? also long running task is cheaper than long running lambda.

@agnusha
Copy link

agnusha commented Jun 9, 2021

For me helped next actions:

  1. waitUntil: ['load', 'networkidle0', 'networkidle2']
  2. return await chromium.puppeteer.launch({
    args: [
    ...chromium.args,
    '--disable-features=AudioServiceOutOfProcess',
    '--disable-gpu',
    '--disable-software-rasterize',
    ]
    ....
  3. use await where it's need
  4. pupeteer has a limit of tabs, so I created a locker class and after 7 tabs close browser and open again.
  5. versions
    "@types/puppeteer": "^2.0.1",
    "@types/puppeteer-core": "^5.4.0",
    "puppeteer": "^5.5.0",
    "puppeteer-core": "^5.5.0",

Downgrating of pupeteer did't helped for me, so it's my solution.

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