fix: replace networkidle0 with load + image-complete wait for file:// pages
networkidle0 is unreliable for large local documents; explicit image decode check is more robust. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+7
-1
@@ -101,7 +101,13 @@ async function generate() {
|
|||||||
page.setDefaultNavigationTimeout(120_000);
|
page.setDefaultNavigationTimeout(120_000);
|
||||||
page.setDefaultTimeout(120_000);
|
page.setDefaultTimeout(120_000);
|
||||||
|
|
||||||
await page.goto(`file://${inputPath}`, { waitUntil: 'networkidle0', timeout: 120_000 });
|
await page.goto(`file://${inputPath}`, { waitUntil: 'load', timeout: 120_000 });
|
||||||
|
|
||||||
|
// Wait until every <img> has finished decoding (handles large local images)
|
||||||
|
await page.waitForFunction(
|
||||||
|
() => [...document.images].every(img => img.complete && img.naturalHeight > 0),
|
||||||
|
{ timeout: 120_000 },
|
||||||
|
);
|
||||||
|
|
||||||
// Write to temp file first so Ghostscript can read it
|
// Write to temp file first so Ghostscript can read it
|
||||||
await page.pdf({
|
await page.pdf({
|
||||||
|
|||||||
Reference in New Issue
Block a user