Reputation:
I use jsreport-core in my node project to generate PDF or XLSX files, to generate PDF I use the library jsreport-chrome-pdf that use puppeteer for rendering, and handlebars for HTML templating.
For small HTML tables without a lot of data, the rendering is really fast on every side but when I need to render really huge tables (around 1400 pages, 7 columns / ~60 rows per page) I get a timeout after 60s. The problem is when I increase this timeout; I get this new error (the title) and I don't understand what that means, I think it is because puppeteer can't handle the processing of all the data but I wanted to know if there was a solution.
I tried different versions of jsreport-core and jsreport-chrome-pdf but no changes on this side. I also tried to delete elements of my template (CSS, helpers, conditions, etc.) to see if this was the problem but no changes either.
Precisions : My template doesn't have images or other heavy elements, it's just a lot of plain text in huge tables.
This is my configurations of both packages :
const jsreport = require('@jsreport/jsreport-core')({
allowLocalFilesAccess: true,
reportTimeout: 600000,
templatingEngines: { timeout: 600000 },
sandbox: { cache: { max: 500 } },
workers: { numberOfWorkers: 5 }
});
.use(require('@jsreport/jsreport-chrome-pdf')({
timeout: 600000,
launchOptions: {
headless: true,
args: [
'--disable-gl-drawing-for-tests',
'--headless',
'--enable-webgl',
'--hide-scrollbars',
'--mute-audio',
'--use-gl=swiftshader',
'--disable-canvas-aa',
'--disable-2d-canvas-clip-aa',
'--disable-gpu',
'--full-memory-crash-report',
'--unlimited-storage'
]
}
}))
I tried to optimise these as much as I could to improve the performance but I think the problem is somewhere else.
I precise : I also tried to generate an HTML file directly, and no problem there, data are entirely shown and the generation take ~500ms.
The full error, if it can be useful :
ProtocolError: Protocol error (Page.printToPDF): Printing failed
at C:\dev\xplanet\srv\node_modules\puppeteer\lib\cjs\puppeteer\common\Connection.js:286:24
at new Promise (<anonymous>)
at CDPSession.send (C:\dev\xplanet\srv\node_modules\puppeteer\lib\cjs\puppeteer\common\Connection.js:282:16)
at Page.createPDFStream (C:\dev\xplanet\srv\node_modules\puppeteer\lib\cjs\puppeteer\common\Page.js:1963:85)
at Page.pdf (C:\dev\xplanet\srv\node_modules\puppeteer\lib\cjs\puppeteer\common\Page.js:1993:37)
at C:\dev\xplanet\srv\node_modules\@jsreport\jsreport-chrome-pdf\lib\conversion.js:363:27
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async C:\dev\xplanet\srv\node_modules\@jsreport\jsreport-chrome-pdf\lib\conversion.js:404:22
Upvotes: 0
Views: 3271