Open Hideman85 opened 2 years ago
Have you tried downgrading to 9.1.0? I also had the same issues with pdf generation until I tried downgrading. Haven't seen any errors since then.
No I did the reverse way, I upgraded to beta 12x and for now it looks to work. I look over the web and it says most of the time this issue rise when chrome crash for rendering the pdf. The v12 of puppeteer has more meaningful error messages and some fixes in addition it come with a more recent chrome with lot of fixes too. Hopefully I will not have a crash anymore or at least a error that mean something that I can deal with :)
Hi, I'm having troubles sometimes with generating pdf...
Code
```js /** **************************************************************************************** * Use puppeteer for generating our pdf from the html document **************************************************************************************** */ console.info('Will start soon the browser') const browser = await chromium.puppeteer.launch({ args: chromium.args, defaultViewport: chromium.defaultViewport, executablePath: await chromium.executablePath, headless: true, ignoreHTTPSErrors: true, pipe: true // Use pipe instead of websocket to avoid load issue }) console.info('const browser = await chromium.puppeteer.launch(...)') const page = await browser.newPage() console.info('const page = await browser.newPage()') await page.setBypassCSP(true) console.info('await page.setBypassCSP(true)') await page.setContent(fileString, { waitUntil: ['load', 'domcontentloaded', 'networkidle0'] }) console.info('await page.setContent(...)') let pdfBuffer = await page.pdf({ printBackground: true, displayHeaderFooter: true, headerTemplate: header, footerTemplate: footer, margin: { top: `${styling.top + styling.headerSpacingOuter}mm`, bottom: `${styling.bottom + styling.footerSpacingOuter}mm`, left: `${styling.left}mm`, right: `${styling.right}mm` }, format: 'A4', preferCSSPageSize: true }) console.info('await page.pdf(...)') await browser.close() console.info('await browser.close()') ```I tried to add extra options from recommended ones and it behaves even crazier...
Options
```js const browser = await chromium.puppeteer.launch({ args: [ // From node_modules/chrome-aws-lambda/build/index.js '--allow-running-insecure-content', '--autoplay-policy=user-gesture-required', '--disable-component-update', '--disable-domain-reliability', '--disable-features=AudioServiceOutOfProcess,IsolateOrigins,site-per-process', '--disable-print-preview', '--disable-setuid-sandbox', '--disable-site-isolation-trials', '--disable-speech-api', '--disable-web-security', '--disk-cache-size=33554432', '--enable-features=SharedArrayBuffer', '--hide-scrollbars', '--ignore-gpu-blocklist', '--in-process-gpu', '--mute-audio', '--no-default-browser-check', '--no-pings', '--no-sandbox', '--no-zygote', '--use-gl=swiftshader', '--window-size=1920,1080', '--single-process', // Additional '--disable-gpu', '--disable-dev-shm-usage', '--disable-sync', '--disable-breakpad', '--disable-default-apps', '--disable-extensions', '--no-first-run', '--disable-component-extensions-with-background-pages', '--disable-client-side-phishing-detection', '--run-all-compositor-stages-before-draw' ], defaultViewport: chromium.defaultViewport, executablePath: await chromium.executablePath, headless: true, ignoreHTTPSErrors: true, pipe: true // Use pipe instead of websocket to avoid load issue }) ```I'm using the latest version 10.1.0 with a lambda layer created out of this:
I would really like to know what am I missing and how I can make the rendering more stable :wink: