Skip to content

Conversation

@guybedford
Copy link

@guybedford guybedford commented Sep 26, 2025

Updates to the latest 2.6.0 release.

Removes the wasm-pack dependency using wasm-bindgen-cli directly and updates the library wrapper to build the latest API.

The only way this build works is by carefully locking the toolchain back to the snapshot in time when it worked, this is because:

  1. wasm-opt's asyncify does not support reference types, which are output for newer versions of Rust and wasm-bindgen.
  2. JSPI is the alternative to wasm-opt but is not yet supported in wasm-bindgen to be able to work as a replacement (I did actually spend over a day trying to implement JSPI for wasm-bindgen, but there are some deep complexities to that such that it isn't a day of work, but discussions are ongoing within the wasm-bindgen project - this was a useful bump to re-initiate those discussions and bring to mind the architectural questions at least!). Even with JSPI, it is only supported in Node.js 24+ which likely doesn't hit the compat requirements here.
  3. Even keeping the Rust toolchain locked, when I updated to newer versions of wasm-bindgen, it implements stricter guards around object management that actually cause many lifetime errors (well, 6 out of 68 tests, not terrible but not great). This actually gets to a deeper fundamental issue with the approach though that the lifetime model implemented here isn't formally safe.

So this gets lolhtml updated, but only in the window that lolhtml still builds on Rust 0.80. That is still going to be a problem in keeping this updated.

As for solving the async model consistency - many of us in wasm-bindgen think these issues can't be solved for asyncify or JSPI - that we are in UB when we apply these models to Wasm code from Rust. One option to get wasm-bindgen updated could be turn off the newer validations, but also just "turning off the validations" isn't really a viable upstream approach without making full sense of the model.

Therefore I would recommend going forward:

  • Ask lol-html maintainers very nicely for now to keep MSRV as Rust 1.80 for as long as possible (it's exactly 1.80 right now by sheer luck, any higher and this wouldn't build)
  • In 2-3 years when Node.js 24+ is okay as as the minimum, move over to a JSPI approach (we will likely have wasm-bindgen progress here by then), allowing the Rust upgrade path and removal of the MSRV requirement.
  • Seriously consider implementing a futures-based handler API for lol-html so that we can represent the async handlers as Rust futures, and not need asyncify or JSPI at all. Getting upstream lol-html mainers to support such an API would side-step all the asyncify/JSPI issues here.

For now, this should work completely fine to keep things going.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant