From 38ac178ab739d8b319e95372f4e7df248941a7a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Kr=C3=BCger?= Date: Mon, 4 May 2026 21:19:55 +0200 Subject: [PATCH] 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 --- scripts/pdf.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/pdf.js b/scripts/pdf.js index 6bf30f5..b4918d8 100644 --- a/scripts/pdf.js +++ b/scripts/pdf.js @@ -101,7 +101,13 @@ async function generate() { page.setDefaultNavigationTimeout(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 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 await page.pdf({