2

I'm trying to use Puppeteer + Firebase Functions while using the headless: false option

await puppeteer.launch({
        headless: false
    });

It works well locally. I use the headless: false so it won't trigger a bot check, which work well.

When I deploy it to Firebase Functions it doesn't seem to be able to launch a browser:

Error: Failed to launch the browser process!

[15:32:0209/162803.759118:ERROR:file_path_watcher_linux.cc(78)] Failed to read /proc/sys/fs/inotify/max_user_watches

[15:15:0209/162804.834741:ERROR:ozone_platform_x11.cc(234)] Missing X server or $DISPLAY

[15:15:0209/162804.834794:ERROR:env.cc(225)] The platform failed to initialize. Exiting.

Is there some sort of a solution to run it as a Firebase Function?

mik
  • 799
  • 9
  • 31
  • Hi! Can you please share feedback on my answer to know if further assistance is needed? – Alex Feb 17 '22 at 15:14

1 Answers1

0

I’ll start with the cases that combined Cloud functions and Puppeteer. Here is an old question that discusses the same log error. I think this is the first place to look for a solution, as it provides links to a couple of Github Issues reporting similar error logs. In this other Github issue, a user recommended code to start Puppeteer in Cloud functions. This example can help you as well.

I’ll leave these two guides that can walk you through. This old medium article and this more updated version from logrocket.

Other question has several workarounds; unfortunately, none of them include Cloud Functions, just in case this is caused purely by Puppeteer. And here is how to run Headful Mode.

However, if you want to avoid being detected by the bot, there is also a discussion about this that could give you some hints.

There is no exact solution for this, as it seems there are several causes and workarounds. I would advise you to open a new question once you have tried some alternatives already provided by the community, and see if there's a more specific solution.

Alex
  • 778
  • 1
  • 15
  • It didn't help, I'm aiming for Firebase Functions and Headful – mik Feb 17 '22 at 19:34
  • It would be much appreciated if you could share what you have tried so far and if those workarounds have given you any logs or information useful to find a solution. The first link involves a very similar case with Cloud Functions and headless (Puppeteer). Both versions of Cloud Functions are very similar. See [What is the difference between Cloud Functions and Firebase Functions?](https://stackoverflow.com/questions/42854865) – Alex Feb 21 '22 at 20:41