"Fix: PDF rendering timeout on page.goto with networkidle"#800
"Fix: PDF rendering timeout on page.goto with networkidle"#800vinsmokejazz wants to merge 1 commit into
Conversation
…rkidle - Changed page.goto() wait_until from 'networkidle' to 'domcontentloaded' - Added explicit timeouts: goto (15s), selector (10s), fonts (10s) - Wrapped document.fonts.ready in try/except for graceful failure - Fixes issue: Page.goto timeout when rendering resumes to PDF Fixes srbhr#799
| await page.goto(url, wait_until="networkidle") | ||
| await page.wait_for_selector(selector) | ||
| await page.evaluate("document.fonts.ready") | ||
| await page.goto(url, wait_until="domcontentloaded", timeout=15000) |
There was a problem hiding this comment.
Great fix! The domcontentloaded strategy is the right approach for static PDF rendering.
One suggestion: the bare except Exception: pass on document.fonts.ready silently swallows font loading failures, which makes production debugging difficult. Consider adding a logger.warning(...) so operators can see when fonts fail to load without blocking PDF generation.
Example:
try:
await page.evaluate("document.fonts.ready", timeout=10000)
except Exception as e:
logger.warning(f"Font loading failed for PDF generation (non-critical): {e}")This is a small addition but significantly improves observability in production environments.
There was a problem hiding this comment.
Thanks for the review and the suggestion!
You're absolutely right, silently swallowing the exception reduces visibility into font-loading issues in production. Adding a non-blocking warning log is a good balance between reliability and observability
Description
Fixes #799
Changes
wait_until="networkidle"towait_until="domcontentloaded"in_render_page_to_pdf()Testing
Summary by cubic
Fixes PDF rendering timeouts by switching navigation wait to
domcontentloadedand adding per-step timeouts, so resume PDFs generate reliably in ~10–15s.page.goto(..., wait_until="domcontentloaded", timeout=15000)to avoid hangs onnetworkidle.document.fonts.readyin try/except so font issues don’t block PDF rendering.Written for commit a29f216. Summary will update on new commits.