You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I'm having troubles sometimes with generating pdf...
Code
/** **************************************************************************************** * Use puppeteer for generating our pdf from the html document **************************************************************************************** */console.info('Will start soon the browser')constbrowser=awaitchromium.puppeteer.launch({args: chromium.args,defaultViewport: chromium.defaultViewport,executablePath: awaitchromium.executablePath,headless: true,ignoreHTTPSErrors: true,pipe: true// Use pipe instead of websocket to avoid load issue})console.info('const browser = await chromium.puppeteer.launch(...)')constpage=awaitbrowser.newPage()console.info('const page = await browser.newPage()')awaitpage.setBypassCSP(true)console.info('await page.setBypassCSP(true)')awaitpage.setContent(fileString,{waitUntil: ['load','domcontentloaded','networkidle0']})console.info('await page.setContent(...)')letpdfBuffer=awaitpage.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(...)')awaitbrowser.close()console.info('await browser.close()')
errorType: 'Error',
stack: 'Error: Protocol error (Page.printToPDF): Target closed.\n' +
' at /opt/nodejs/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Connection.js:208:63\n' +
' at new Promise (<anonymous>)\n' +
' at CDPSession.send (/opt/nodejs/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Connection.js:207:16)\n' +
' at Page.pdf (/opt/nodejs/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Page.js:1220:43)\n' +
' at /var/task/index.js:649:30\n' +
I tried to add extra options from recommended ones and it behaves even crazier...
Options
constbrowser=awaitchromium.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: awaitchromium.executablePath,headless: true,ignoreHTTPSErrors: true,pipe: true// Use pipe instead of websocket to avoid load issue})
errorType: 'TimeoutError',
stack: 'TimeoutError: waiting for target failed: timeout 30000ms exceeded\n' +
' at Object.waitWithTimeout (/opt/nodejs/node_modules/puppeteer-core/lib/cjs/puppeteer/common/helper.js:224:26)\n' +
' at Browser.waitForTarget (/opt/nodejs/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Browser.js:296:45)\n' +
' at ChromeLauncher.launch (/opt/nodejs/node_modules/puppeteer-core/lib/cjs/puppeteer/node/Launcher.js:105:31)\n' +
' at async /var/task/index.js:637:19\n' +
message: 'waiting for target failed: timeout 30000ms exceeded',
name: 'TimeoutError',
I'm using the latest version 10.1.0 with a lambda layer created out of this:
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
I tried to add extra options from recommended ones and it behaves even crazier...
Options
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 😉
The text was updated successfully, but these errors were encountered: