gpt4 book ai didi

puppeteer - 获取 "TimeoutError: waiting for Page.printToPDF failed"时如何增加 pupetteer 的 Page.pdf 的超时?

转载 作者:行者123 更新时间:2023-12-05 02:38:51 55 4
gpt4 key购买 nike

尝试将大发票转换为 PDF 时出现“超时错误:WAITING Page.printToPDF 失败”:

Unhandled Rejection at: Promise Promise { <rejected>
TimeoutError: waiting for Page.printToPDF failed: timeout 30000ms exceeded

at Object.waitWithTimeout (/var/www/montbeau/releases/20210929161149/node_modules/puppeteer/lib/cjs/puppeteer/common/helper.js:224:26)

at Page.createPDFStream (/var/www/montbeau/releases/20210929161149/node_modules/puppeteer/lib/cjs/puppeteer/common/Page.js:2045:49)

at Page.pdf (/var/www/montbeau/releases/20210929161149/node_modules/puppeteer/lib/cjs/puppeteer/common/Page.js:2057:37)

at /var/www/montbeau/releases/20210929161149/scripts/invoice_to_pdf.js:175:20

at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
} reason: TimeoutError: waiting for Page.printToPDF failed: timeout
30000ms exceeded

at Object.waitWithTimeout (/var/www/montbeau/releases/20210929161149/node_modules/puppeteer/lib/cjs/puppeteer/common/helper.js:224:26)

at Page.createPDFStream (/var/www/montbeau/releases/20210929161149/node_modules/puppeteer/lib/cjs/puppeteer/common/Page.js:2045:49)

at Page.pdf (/var/www/montbeau/releases/20210929161149/node_modules/puppeteer/lib/cjs/puppeteer/common/Page.js:2057:37)

at /var/www/montbeau/releases/20210929161149/scripts/invoice_to_pdf.js:175:20...

如何增加超时时间?

最佳答案

puppeteer/lib/cjs/puppeteer/common/Page.jscreatePDFStream 方法中,超时作为一个选项出现:

2007         const { scale = 1, displayHeaderFooter = false, headerTemplate = '', footerTemplate = '', printBackground = false, landscapdscape = false, pageRanges = '', preferCSSPageSize = false, margin = {}, omitBackground = false, timeout = 30000, } = options;
[...]
2045 const result = await helper_js_1.helper.waitWithTimeout(printCommandPromise, 'Page.printToPDF', timeout);

所以尽管 timeout 不是 https://github.com/puppeteer/puppeteer/blob/main/docs/api.md#pagepdfoptions 的记录选项, 它似乎确实是 .pdf 方法的一个选项。

关于puppeteer - 获取 "TimeoutError: waiting for Page.printToPDF failed"时如何增加 pupetteer 的 Page.pdf 的超时?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69436420/

55 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com