spatie / laravel-pdf

Create PDF files in Laravel apps
https://spatie.be/docs/laravel-pdf
MIT License
715 stars 54 forks source link

[Bug]: Browser instance crashes with puppeteer from version 22.* #97

Closed blauweb closed 8 months ago

blauweb commented 8 months ago

What happened?

I get this error when attempting to generate a PDF from view, using puppeteer version 22.* for laravel-pdf: The command "PATH=$PATH:/usr/local/bin:/opt/homebrew/bin NODE_PATH=npm root -g node '/var/www/[project]/vendor/spatie/browsershot/src/../bin/browser.cjs' '{"url":"file:\/\/\/tmp\/1258003998-0789288001709851462\/index.html","action":"pdf","options":{"args":[],"viewport":{"width":800,"height":600},"displayHeaderFooter":false,"printBackground":true}}'" failed. Exit Code: 1(General error) Working directory: /var/www/[project]/public Output: ================ Error Output: ================ Error: Failed to launch the browser process! chrome_crashpad_handler: --database is required Try 'chrome_crashpad_handler --help' for more information. [103327:103327:0307/234423.046451:ERROR:socket.cc(120)] recvmsg: Connection reset by peer (104) TROUBLESHOOTING: https://pptr.dev/troubleshooting at Interface.onClose (/var/www/[project]/node_modules/@puppeteer/browsers/lib/cjs/launch.js:267:24) at Interface.emit (node:events:526:35) at Interface.close (node:internal/readline/interface:533:10) at Socket.onend (node:internal/readline/interface:259:10) at Socket.emit (node:events:526:35) at endReadableNT (node:internal/streams/readable:1359:12) at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

Puppeteer was installed using the suggested config files, to have the chrome instances loaded into the projects folder, instead of the system user folder.

Puppeteer itself is not issue, because when attempting to read data from a page using the JS in a separate JS file, and then running it via node, puppeteer is able to open, read and close a page without issues.

The error does not happen with puppeteer version below <22.0!

When reading the changelog at puppeteer, it looks like something has changed with the browser sessions.

Environment: Ubuntu 22.0

How to reproduce the bug

  1. Install THIS package and any puppeteer version starting from 22.* within your project, using the recommended config files to store the chrome files within the project folder.
  2. Generate PDF along with download command.

Package Version

1.4.0

PHP Version

8.2

Laravel Version

10

Which operating systems does with happen with?

Linux

Notes

No response