Skip to content

fix(pdf): avoid networkidle wait during render#929

Merged
santifer merged 1 commit into
santifer:mainfrom
luochen211:fix/863-pdf-load-wait
Jun 11, 2026
Merged

fix(pdf): avoid networkidle wait during render#929
santifer merged 1 commit into
santifer:mainfrom
luochen211:fix/863-pdf-load-wait

Conversation

@luochen211

@luochen211 luochen211 commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Summary

  • switch HTML-to-PDF rendering from networkidle to load so open background requests do not stall printing
  • add a regression assertion in test-all.mjs for the PDF render wait condition

Fixes #863

Validation

  • node test-all.mjs --quick (232 passed, 0 failed; existing README personal-data warnings)

Summary by CodeRabbit

  • Bug Fixes

    • Improved PDF generation performance by optimizing the content initialization timing before rendering begins.
  • Tests

    • Added test validation to ensure PDF rendering configuration is properly maintained.

@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: f3d07b54-3344-4476-9f2f-2f3845d23d97

📥 Commits

Reviewing files that changed from the base of the PR and between edc971a and b827bcd.

📒 Files selected for processing (2)
  • generate-pdf.mjs
  • test-all.mjs

📝 Walkthrough

Walkthrough

This PR changes the PDF rendering wait condition from networkidle to load in generate-pdf.mjs to prevent rendering hangs when background network activity remains open. A validation test is added to test-all.mjs to enforce this configuration.

Changes

PDF rendering wait condition

Layer / File(s) Summary
PDF rendering wait condition
generate-pdf.mjs
page.setContent in renderHtmlToPdf changes waitUntil from networkidle to load, allowing PDF generation to proceed once the document is loaded rather than waiting for all network activity to complete.
Wait condition validation test
test-all.mjs
New validation block asserts that generate-pdf.mjs contains waitUntil: 'load' and does not contain waitUntil: 'networkidle', running after absolute-path checks.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Suggested labels

🔧 scripts

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: switching from networkidle to load in PDF rendering to avoid stalls.
Linked Issues check ✅ Passed The changes fully implement the proposed fix from issue #863: replacing waitUntil 'networkidle' with 'load' in generate-pdf.mjs and adding regression test coverage.
Out of Scope Changes check ✅ Passed All changes directly address issue #863's requirements: the waitUntil strategy change and regression test are in scope and necessary.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@santifer santifer merged commit fd2ce04 into santifer:main Jun 11, 2026
8 checks passed
@santifer

Copy link
Copy Markdown
Owner

Merged — that hang was biting real users (#863 came from a live report) and the load-vs-networkidle distinction for self-contained HTML is exactly right. With the two from this morning, that's six in for you today. 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PDF rendering can hang waiting for networkidle on self-contained CV HTML

2 participants