You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bundleToSingleHtml throws "RangeError: Invalid string length" when one image is referenced many times #6133
bundleToSingleHtml inlines every relative image/font under 2 MB as a base64 data URL, once per reference. The 2 MB limit is per asset, so nothing bounds the bundle as a whole: a 1.4 MB image referenced 400 times writes ~750M characters, past V8's max string length (~2^29). Under Node, check, snapshot and render then fail with RangeError: Invalid string length. (Bun has a higher limit, so this only shows on Node.)
We hit this in production on lessons that repeat a counting unit (e.g. 63 copies of a 1.1 MB chair image).
#6134 only stops the crash: it caps the total inlined size and leaves bundles under the cap unchanged. The underlying waste is still there: an asset referenced N times is written N times.
Would you be open to deduplicating inlined assets by default? HTML has no way to share one payload across <img src>, srcset, CSS url() and @font-face, so the options I see are:
Runtime rehydration: emit each asset once (e.g. in a <script type="application/octet-stream">), turn it into a blob URL at load, and rewrite every reference. This covers every reference type. Trade-offs:
images only get a src after the script runs, so render/seek would need to wait for rehydration before the first frame
the bundle no longer works without JS
srcset, <picture>, inline styles, stylesheets and fonts each need their own rewrite
CSS custom properties: one --asset-N: url(data:…) per asset. No JS, but it only covers background-image, not <img> or fonts.
If dedup by default sounds right to you, I'm happy to implement option 1 behind whatever readiness hook render already uses. Otherwise the cap in #6134 is enough for our case.
Activity
cauyxy commentedon Oct 23, 2026
#6134 only stops the crash: it caps the total inlined size and leaves bundles under the cap unchanged. The underlying waste is still there: an asset referenced N times is written N times.
Would you be open to deduplicating inlined assets by default? HTML has no way to share one payload across
<img src>,srcset, CSSurl()and@font-face, so the options I see are:<script type="application/octet-stream">), turn it into a blob URL at load, and rewrite every reference. This covers every reference type. Trade-offs:srcafter the script runs, so render/seek would need to wait for rehydration before the first framesrcset,<picture>, inline styles, stylesheets and fonts each need their own rewrite--asset-N: url(data:…)per asset. No JS, but it only coversbackground-image, not<img>or fonts.If dedup by default sounds right to you, I'm happy to implement option 1 behind whatever readiness hook render already uses. Otherwise the cap in #6134 is enough for our case.