spiritix / php-chrome-html2pdf

A PHP library for converting HTML to PDF using Google Chrome
MIT License
107 stars 29 forks source link

Failed To Launch Browser Process #76

Open zpottie opened 10 hours ago

zpottie commented 10 hours ago

Hi there,

Apologies if I'm polluting your issues, but just wanted to put this here in case it helps someone else, as I came looking here first as we use your library.

Redeployed our code today and PDF generation broke. Looks like it may be a bug introduced by Chrome? https://github.com/chrome-php/chrome/issues/649

Uncaught PHP Exception Spiritix\Html2Pdf\ConverterException: "Binary error: file:///PATH/TO/PROJECT/vendor/spiritix/php-chrome-html2pdf/node_modules/@puppeteer/browsers/lib/esm/launch.js:301
    reject(new Error([                        
        ^  Error: Failed to launch the browser process! chrome_crashpad_handler: --database is required Try 'chrome_crashpad_handler --help' for more information. [1796849:1796849:1008/000936.708637:ERROR:socket.cc(120)] recvmsg: Connection reset by peer (104)   TROUBLESHOOTING: https://pptr.dev/troubleshooting      at Interface.onClose (file:///PATH/TO/PROJECT/vendor/spiritix/php-chrome-html2pdf/node_modules/@puppeteer/browsers/lib/esm/launch.js:301:24)     at Interface.emit (node:events:529:35)     at Interface.close (node:internal/readline/interface:534:10)     at Socket.onend (node:internal/readline/interface:260:10)     at Socket.emit (node:events:529:35)     at endReadableNT (node:internal/streams/readable:1400:12)     at process.processTicksAndRejections (node:internal/process/task_queues:82:21)  Node.js v18.20.4 " at Converter.php line 271...

Hope this helps someone else!

zpottie commented 10 hours ago

What ended up working for me, or at least a work-around for now, is to create the directories like mentioned in the linked issue: https://github.com/chrome-php/chrome/issues/649#issuecomment-2336592370

sudo mkdir -p /home/www/.config/google-chrome/Crashpad
sudo chown -R www-data:www-data /home/www/.config