Skip to content

Conversation

@eKoopmans
Copy link
Owner

@eKoopmans eKoopmans commented Aug 24, 2025

This PR adds a small 10ms delay after cloning nodes, to improve the chances that the content is properly rendered before capturing with html2canvas. This isn't ideal (it'll make every call slower by 10ms and still doesn't guarantee anything), but should reduce flakiness.

This was impacting vdiffs and some local demos, which suggests that it may be a noticeable problem in prod as well. It was causing images to sometimes be cut off - the page height was calculated too small, since content wasn't fully rendered and hadn't reflowed to their final sizes.


A better solution would involve not cloning the content myself at all, and leaving window sizing etc to the image-capturing tool (html2canvas). There's a branch I created way back in 2019 to do just that:
https://github.com/eKoopmans/html2pdf.js/tree/bugfix/clone-nodes

Didn't want to jump straight to that solution though, because it'll introduce its own issues and will be a breaking change (no toContainer step etc).

@eKoopmans eKoopmans merged commit 32d006f into main Aug 24, 2025
3 checks passed
@eKoopmans eKoopmans deleted the ekoopmans/fix-timing branch August 24, 2025 00:27
@ekoopmans-github-release-tokens
Copy link
Contributor

🎉 This PR is included in version 0.11.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants