Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Puppeteer blocked at .newPage()

I want to use Puppeteer to generate PDF.

My environnement dev

  • WSL2 Debian Buster
  • Node v12.18.1
  • npm 7.5.4
  • Puppeteer 8.0.0

I tried many tutorials on the web to do it. But the code is blocked on browser.newPage()

const browser = await puppeteer.launch();
console.log(await browser.version()); //HeadlessChrome/90.0.4427.0 
const page = await browser.newPage(); //after it does nothing

Here the debug (six last lines) :

  puppeteer:protocol:RECV ◀ {"id":4,"result":{"sessionId":"B3D2567E07203D4A096A495710466966"}} +0ms
  puppeteer:protocol:SEND ► {"sessionId":"B3D2567E07203D4A096A495710466966","method":"Page.enable","params":{},"id":5} +1ms
  puppeteer:protocol:SEND ► {"sessionId":"B3D2567E07203D4A096A495710466966","method":"Page.getFrameTree","params":{},"id":6} +1ms
  puppeteer:protocol:SEND ► {"sessionId":"B3D2567E07203D4A096A495710466966","method":"Target.setAutoAttach","params":{"autoAttach":true,"waitForDebuggerOnStart":false,"flatten":true},"id
":7} +0ms
  puppeteer:protocol:SEND ► {"sessionId":"B3D2567E07203D4A096A495710466966","method":"Performance.enable","params":{},"id":8} +0ms
  puppeteer:protocol:SEND ► {"sessionId":"B3D2567E07203D4A096A495710466966","method":"Log.enable","params":{},"id":9} +0ms

Thanks,

like image 359
Rifton007 Avatar asked Nov 16 '25 09:11

Rifton007


1 Answers

I have fixed the issue of my case:

Use dumpio: true to display log of Puppeteer. After that, I found the error with libX11-xcb.so.1 and disabled the gpu.

  browser = await chromium.launch({
      args: ["--disable-gpu"]
    });

https://github.com/puppeteer/puppeteer/issues/1543#issuecomment-349642975 https://github.com/microsoft/playwright/issues/4761#issue-770834723

like image 146
Rifton007 Avatar answered Nov 19 '25 07:11

Rifton007



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!