Skip to content

ci: pin binaryen / wasm-opt for deterministic WASM builds (SQLR-58)#138

Merged
joaoh82 merged 1 commit into
mainfrom
sqlr-58-pin-binaryen
May 12, 2026
Merged

ci: pin binaryen / wasm-opt for deterministic WASM builds (SQLR-58)#138
joaoh82 merged 1 commit into
mainfrom
sqlr-58-pin-binaryen

Conversation

@joaoh82
Copy link
Copy Markdown
Owner

@joaoh82 joaoh82 commented May 12, 2026

Summary

  • Pin binaryen (provides wasm-opt) to version_122 in both ci.yml (wasm-build) and release.yml (publish-wasm) by downloading the official GitHub release tarball before wasm-pack runs and prepending it to PATH.
  • wasm-pack auto-detects wasm-opt on PATH (and falls back to its internal binaryen cache otherwise) — so this single change is enough to force a deterministic wasm-opt across runner image cache states.
  • Document the pin + bump procedure in docs/release-plan.md.

Why

PR #135 flaked with:

[parse exception: Only 1 table definition allowed in MVP (at 0:11235)]
Fatal: error in parsing input
Error: failed to execute `wasm-opt`: exited with exit code: 1

Root cause: jetli/wasm-pack-action and wasm-pack's curl-installer both let wasm-pack use whatever binaryen its per-runner cache happens to hold. Older binaryen rejects rustc's multi-table WASM output. The same commit shipped successfully on a rerun (different cache state) and via the release pipeline — proving it's a binaryen-version flake, not a code regression. The release pipeline can't tolerate this: a failed publish-wasm leaves the release wave inconsistent.

Why option 2 (pin via tarball)

  • Option 1 (disable wasm-opt) would ship a 5–15% larger bundle on every user. Not worth it.
  • Option 3 (bump jetli/wasm-pack-action) doesn't actually fix this — that action installs wasm-pack, which itself picks the binaryen version. No newer tag of jetli/wasm-pack-action solves the binaryen problem.
  • Option 2 (pin binaryen tarball + put on PATH) is what landed: keeps wasm-opt's size optimization, removes the cache-roulette behavior, and turns binaryen bumps into a deliberate two-file diff.

Verified locally

wasm-pack build --target web --release with the pinned binaryen on PATH:

[INFO]: found wasm-opt at "/tmp/sqlr58-binaryen/binaryen-version_122/bin/wasm-opt"
[INFO]: Optimizing wasm binaries with `wasm-opt`...
[INFO]: ✨   Done in 35.82s

Output bundle: 2.14 MiB — in line with prior sizes (the v0.10.0 release WASM bundle was ~2.1 MiB).

Test plan

  • CI wasm-build job passes on this PR.
  • CI logs show wasm-opt version 122 (version_122) in the "Install pinned binaryen" + "wasm-pack build" steps.
  • Re-run the wasm-build job 2–3 times — pass on each run (proving determinism).
  • release.yml's publish-wasm path will be exercised on the next release wave; expectation is the same version_122 line in the build log.

Follow-ups (separate PRs)

  • The sdk/wasm/Cargo.lock is stale — it still pins internal crates at 0.1.23 while Cargo.toml is at 0.10.0. The 0.10.0 bump didn't touch it because sdk/wasm/ is its own workspace and scripts/bump-version.sh doesn't cargo build inside it. Spinning that off into its own ticket; out of scope here.

🤖 Generated with Claude Code

`jetli/wasm-pack-action` and wasm-pack's curl-installer both let wasm-pack
pick whatever binaryen its internal cache happens to hold. When that
copy predates multi-table WASM support, wasm-opt rejects rustc output
with "Only 1 table definition allowed in MVP" — a flake whose
hit/miss depended on runner image cache state (first surfaced on
PR #135; rerun passed). Pin binaryen to version_122 in both the
ci.yml `wasm-build` and release.yml `publish-wasm` jobs by
downloading the official tarball before wasm-pack runs and
prepending it to PATH. wasm-pack auto-detects wasm-opt on PATH, so
no further wiring needed. Bump procedure documented in
docs/release-plan.md so future-me knows to update both workflows
in lockstep.

Verified locally on darwin-arm64: `wasm-pack build --target web
--release` reports `[INFO]: found wasm-opt at ".../binaryen-version_122/bin/wasm-opt"`
and builds a 2.14 MiB bundle (in line with prior sizes).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 12, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
rust-sqlite Ready Ready Preview, Comment May 12, 2026 0:06am

Request Review

@joaoh82 joaoh82 merged commit bdd8017 into main May 12, 2026
46 checks passed
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