2

I have this Puppeteer file I'm trying to run on an Ubuntu server:

var puppeteer = require('puppeteer')

const browser = await puppeteer.launch({
    'headless' : true,
    "executablePath": "/usr/bin/chromium-browser", 
    "args": [
        '--disable-setuid-sandbox',
            '--no-sandbox',
            '--disable-gpu',
            //'--no-first-run' 
    ]
})
const page = await browser.newPage()

It works well on my computer, but when I try to run it on my server I get the below error. I've read many posts on this topic and looked into the troubleshooting file on Github, but nothing works for me.

How can I resolve this issue with running Puppeteer on an Ubuntu server? I'm using the latest version, Ubuntu 18.04.5 LTS.

root@h2922648:~/Test# node test.js
[0620/162429.725764:ERROR:gpu_init.cc(441)] Passthrough is not supported, GL is swiftshader

DevTools listening on ws://127.0.0.1:36132/devtools/browser/6c0ea0f9-d0a8-4fb8-85b9-61e9a2759b67
Start
[0620/162430.186785:ERROR:platform_thread_posix.cc(148)] pthread_create: Die Ressource ist zur Zeit nicht verfügbar (11)
[0620/162430.187119:FATAL:thread_pool_impl.cc(178)] Check failed: service_thread_.StartWithOptions(std::move(service_thread_options)).
#0 0x55670c3baaa9 base::debug::CollectStackTrace()
#1 0x55670c3260e3 base::debug::StackTrace::StackTrace()
#2 0x55670c337730 logging::LogMessage::~LogMessage()
#3 0x55670c33827e logging::LogMessage::~LogMessage()
#4 0x55670c394f80 base::internal::ThreadPoolImpl::Start()
#5 0x55670f84321f content::ChildProcess::ChildProcess()
#6 0x556711078b03 content::RenderProcess::RenderProcess()
#7 0x556711078423 content::RenderProcessImpl::RenderProcessImpl()
#8 0x556711078abb content::RenderProcessImpl::Create()
#9 0x5567117ddce3 content::RendererMain()
#10 0x55670c2c267c content::RunZygote()
#11 0x55670c2c390e content::ContentMainRunnerImpl::Run()
#12 0x55670c2c0f7d content::RunContentProcess()
#13 0x55670c2c191d content::ContentMain()
#14 0x55670c3203b6 headless::(anonymous namespace)::RunContentMain()
#15 0x55670c32011e headless::RunChildProcessIfNeeded()
#16 0x55670c31e9f5 headless::HeadlessShellMain()
#17 0x556709204264 ChromeMain
#18 0x7f3654e01bf7 __libc_start_main
#19 0x5567092040aa _start

Received signal 6
#0 0x55670c3baaa9 base::debug::CollectStackTrace()
#1 0x55670c3260e3 base::debug::StackTrace::StackTrace()
#2 0x55670c3ba5d1 base::debug::(anonymous namespace)::StackDumpSignalHandler()
#3 0x7f365986c980 (/lib/x86_64-linux-gnu/libpthread-2.27.so+0x1297f)
#4 0x7f3654e1efb7 gsignal
#5 0x7f3654e20921 abort
#6 0x55670c3b9895 base::debug::BreakDebugger()
#7 0x55670c337b57 logging::LogMessage::~LogMessage()
#8 0x55670c33827e logging::LogMessage::~LogMessage()
#9 0x55670c394f80 base::internal::ThreadPoolImpl::Start()
#10 0x55670f84321f content::ChildProcess::ChildProcess()
#11 0x556711078b03 content::RenderProcess::RenderProcess()
#12 0x556711078423 content::RenderProcessImpl::RenderProcessImpl()
#13 0x556711078abb content::RenderProcessImpl::Create()
#14 0x5567117ddce3 content::RendererMain()
#15 0x55670c2c267c content::RunZygote()
#16 0x55670c2c390e content::ContentMainRunnerImpl::Run()
#17 0x55670c2c0f7d content::RunContentProcess()
#18 0x55670c2c191d content::ContentMain()
#19 0x55670c3203b6 headless::(anonymous namespace)::RunContentMain()
#20 0x55670c32011e headless::RunChildProcessIfNeeded()
#21 0x55670c31e9f5 headless::HeadlessShellMain()
#22 0x556709204264 ChromeMain
#23 0x7f3654e01bf7 __libc_start_main
#24 0x5567092040aa _start
  r8: 0000000000000000  r9: 00007fffaf96c090 r10: 0000000000000008 r11: 0000000000000246
 r12: 00000fa200488640 r13: 00007fffaf96c2f0 r14: 00000fa200488650 r15: aaaaaaaaaaaaaaaa
  di: 0000000000000002  si: 00007fffaf96c090  bp: 00007fffaf96c2e0  bx: 00007fffaf96cb20
  dx: 0000000000000000  ax: 0000000000000000  cx: ffffffffffffffff  sp: 00007fffaf96c090
  ip: 00007f3654e1efb7 efl: 0000000000000246 cgf: 0000000000000033 erf: 0000000000000000
 trp: 0000000000000000 msk: 0000000000000000 cr2: 0000000000000000
[end of stack trace]
Ben
  • 31
  • 1
  • 5
  • have you installed the google chromium-browser on the server? – Jawad Jun 07 '21 at 18:34
  • Yes and if i try to open it without pupeteer ("chromium-browser --no-sandbox --headless") I get the same error. – Ben Jun 09 '21 at 19:03
  • Ben have you done this on server, i mean installing the browser. apt-get install google-chrome-stable Because i am running it --headless and its working. – Jawad Jun 10 '21 at 19:14
  • Now it kind of works but it just freezes while trying to create a page – Ben Jun 13 '21 at 12:04
  • Ben do not use Answers in order to communicate on our solution, otherwise, you will be rated down. We will communicate here in the comments. Look at my code again and give it a try and look for the generated image – Jawad Jun 15 '21 at 15:55
  • Okay i have edited my Question. – Ben Jun 18 '21 at 08:13
  • Have you installed google chromimum browser on ubuntu/server machine? apt-get install -y google-chrome-stable – Jawad Jun 18 '21 at 09:31
  • you need 'libxss1' plus there are some dependencies you need in ubuntu: apt-get install curl google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 – Jawad Jun 18 '21 at 09:35
  • Yes i have installed all of that – Ben Jun 20 '21 at 14:19
  • just to double-check, open this link and it explain what you need in docker/ubuntu: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md#running-puppeteer-in-docker – Jawad Jun 21 '21 at 12:09

1 Answers1

2

So here I am posting a working code.

In the comments, I have mentioned that what was missing in your code and why we need it.

Make sure that you following already installed in your ubuntu machine:

apt-get install -y curl google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1

It was freezing because we have to close the browser after everything.

I have added dumpio also, it will enable the debug mode.

var puppeteer = require('puppeteer-core')

var adresse = "https://www.google.de/"

async function test() {
try {
    const browser = await puppeteer.launch({
        "dumpio": true,
        "headless": true,
        "executablePath": '/usr/bin/chromium-browser',
        "args": [
            '--disable-setuid-sandbox',
            '--no-sandbox',
            '--disable-gpu',
        ]
    })
    console.log("Start");
    const page = await browser.newPage();
    console.log("1");
    await page.goto(adresse, { waitUntil: ['load', 'networkidle0'] }); // WAIT for the page load finish. Provide wait options, you can read moe about it in documentation.
    console.log("2");
    console.log(page);
    await page.screenshot({path: 'buddy-screenshot.png'}); // WHAT you wanted to do with the page. You can take Screenshot or generate pdf.

    await page.close(); // After job done close the page
    await browser.close(); // IMPORTANT: you have to shutdown the browser in order to proceed with the results.
        
    } catch (error) {
       console.log(error)
    }
}

await test(); // For safe side wait for it.
Jawad
  • 190
  • 10
  • Okay i have edited my Question. There you can see my console output from your code. – Ben Jun 19 '21 at 19:54
  • I have reinstalled my Server and all the dependencies for puppeteer. In my Question you can see the "new error" i get – Ben Jun 20 '21 at 14:28