jontewks/puppeteer-heroku-buildpack

'Error: Failed to launch the browser process!' after trying all suggestions

davicente opened this issue · 9 comments

I'm having this issue that I know have appeared many times. But after checking all possible solutions, noone is working for me. Everything is working fine for me in local, but after deploying in Heroku, I recieve that error:

The error I get:
'Error: Failed to launch the browser process!'

This is how I initialize the browser:
browser = await puppeteer.launch({ headless: true, args: ['--no-sandbox', '--disable-setuid-sandbox'], });

Here the buildpacks added in Heroku
image

I'm a little lost and desperate
I hope you can help me :)

Thanks @davicente lets see what we can do.

First can you post the rest of the error too please?

Hi @jontewks,
first of all, thanks for your fast reply.

This is the stack:

Error: Failed to launch the browser process!
ERROR:platform_thread_posix.cc(148)] pthread_create: Resource temporarily unavailable (11)
FATAL:browser_task_executor.cc(405)] Failed to start BrowserThread:IO
host app worker.1 - #0 0x56251b45c029 base::debug::CollectStackTrace()
host app worker.1 - #1 0x56251b3c3623 base::debug::StackTrace::StackTrace()
host app worker.1 - #2 0x56251b3d68f0 logging::LogMessage::~LogMessage()
host app worker.1 - #3 0x56251938bba6 content::BrowserTaskExecutor::CreateIOThread()
host app worker.1 - #4 0x56251af5e408 content::ContentMainRunnerImpl::RunBrowser()
host app worker.1 - #5 0x56251af5e117 content::ContentMainRunnerImpl::Run()
host app worker.1 - #6 0x56251af5b985 content::RunContentProcess()
host app worker.1 - #7 0x56251af5c45e content::ContentMain()
host app worker.1 - #8 0x56251afba7ce headless::HeadlessBrowserMain()
host app worker.1 - #9 0x56251afba4fd headless::HeadlessShellMain()
host app worker.1 - #10 0x562517d01133 ChromeMain
host app worker.1 - #11 0x7fb491ed50b3 __libc_start_main
host app worker.1 - #12 0x562517d00f6a _start
host app worker.1 - 
host app worker.1 - Received signal 6
host app worker.1 - #0 0x56251b45c029 base::debug::CollectStackTrace()
host app worker.1 - #1 0x56251b3c3623 base::debug::StackTrace::StackTrace()
host app worker.1 - #2 0x56251b45bb01 base::debug::(anonymous namespace)::StackDumpSignalHandler()
host app worker.1 - #3 0x7fb492da63c0 (/usr/lib/x86_64-linux-gnu/libpthread-2.31.so+0x153bf)
host app worker.1 - #4 0x7fb491ef418b gsignal
host app worker.1 - #5 0x7fb491ed3859 abort
host app worker.1 - #6 0x56251b45ad95 base::debug::BreakDebuggerAsyncSafe()
host app worker.1 - #7 0x56251b3d6d1f logging::LogMessage::~LogMessage()
host app worker.1 - #8 0x56251938bba6 content::BrowserTaskExecutor::CreateIOThread()
host app worker.1 - #9 0x56251af5e408 content::ContentMainRunnerImpl::RunBrowser()
host app worker.1 - #10 0x56251af5e117 content::ContentMainRunnerImpl::Run()
host app worker.1 - #11 0x56251af5b985 content::RunContentProcess()
host app worker.1 - #12 0x56251af5c45e content::ContentMain()
host app worker.1 - #13 0x56251afba7ce headless::HeadlessBrowserMain()
host app worker.1 - #14 0x56251afba4fd headless::HeadlessShellMain()
host app worker.1 - #15 0x562517d01133 ChromeMain
host app worker.1 - #16 0x7fb491ed50b3 __libc_start_main
host app worker.1 - #17 0x562517d00f6a _start
[...]

Let me know if you have any idea about the problem.
Regards

@davicente I haven't seen this error before. Have you tried clearing the heroku build cache by chance?
https://help.heroku.com/18PI5RSY/how-do-i-clear-the-build-cache

If that doesn't work, try starting a new heroku app with the same repo, just to be sure we can rule heroku out of the equation.

It looks like it was related with a problem with memory limitation in the pod (in case it happens to anyone again).
Thanks for your support :).

hey @jontewks , this did not work for me.. i deleted cache a couple of times and I get this error everytime..

2022-03-15T20:03:34.549420+00:00 app[web.1]: Chrome Initialize failed:  Error: Failed to launch the browser process!
2022-03-15T20:03:34.549432+00:00 app[web.1]: [133:133:0315/200334.538525:ERROR:ozone_platform_x11.cc(247)] Missing X server or $DISPLAY
2022-03-15T20:03:34.549445+00:00 app[web.1]: [133:133:0315/200334.538571:ERROR:env.cc(225)] The platform failed to initialize.  Exiting.
2022-03-15T20:03:34.549472+00:00 app[web.1]: TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md
2022-03-15T20:03:34.549484+00:00 app[web.1]:     at onClose (/app/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:237:20)
2022-03-15T20:03:34.549499+00:00 app[web.1]:     at ChildProcess.<anonymous> (/app/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:228:79)
2022-03-15T20:03:34.549521+00:00 app[web.1]:     at ChildProcess.emit (events.js:412:35)
2022-03-15T20:03:34.549530+00:00 app[web.1]:     at Process.ChildProcess._handle.onexit (internal/child_process.js:282:12)

any idea why this can be happening?

Works fine on my local environment though but when deployed to heroku, the execution keeps crashing here

@jtourisns hey can you please post your code as well? I see the error references a display, so are you running it in headless mode as Heroku doesn't support headless: false. If you aren't doing that, please open up a new issue and we can see about getting it sorted out.

I see.. that is issue then, I am trying to run it as headless: false. Was not aware that heroku did not supported this feature. So for what you are saying there is absolutely no workaround for launching a puppeteer client with headless: false on heroku?

Correct, as Heroku has no UI to show you what their dynos are doing. If you want to see whats going on there is an option to take a screenshot in puppeteer and you can then see what is happening at that point in time.

It looks like it was related with a problem with memory limitation in the pod (in case it happens to anyone again).
Thanks for your support :).

@davicente What type of dyno have you ended up using?