Skip to content

SRE-868: Replace cargo:wasm-opt with prebuilt Binaryen in mise config - #9105

Draft
claude[bot] wants to merge 2 commits into
mainfrom
claude/sre-868-wasm-opt-prebuilt
Draft

SRE-868: Replace cargo:wasm-opt with prebuilt Binaryen in mise config#9105
claude[bot] wants to merge 2 commits into
mainfrom
claude/sre-868-wasm-opt-prebuilt

Conversation

@claude

@claude claude Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Requested by Ciaran Morinan, Tim Diekmann · Slack thread

🌟 What is the purpose of this PR?

Before: every Vercel frontend build spent ~6m54s — roughly 75% of the 9-minute install phase — compiling the wasm-opt crate from source. cargo-binstall can never find a prebuilt binary for it, because the crates.io wasm-opt crate (brson/wasm-opt-rs) publishes no release binaries; the real prebuilt wasm-opt binaries live in WebAssembly/binaryen releases.

After: wasm-opt comes from the prebuilt Binaryen version_131 release binaries on every platform — Vercel installs, CI, and the linux/arm64 Docker image builds (version_131 is the first Binaryen release that ships an aarch64-linux asset). Downloads take seconds, and cargo:wasm-opt is removed entirely: one tool, one version, everywhere.

How: "github:WebAssembly/binaryen" = "version_131" uses mise's github backend to install release assets directly. The aqua backend was considered first (its registry converts Binaryen's version_131-style tags, which keeps renovate updates working, per Bilal) — but the aqua registry constrains binaryen ≥ 108 to supported_envs: [darwin, amd64] and has no arm64→aarch64 asset-name mapping for linux, so aqua:WebAssembly/binaryen fails on linux/arm64 at any version and can't serve the arm64 Docker builds. An upstream aqua-registry PR adding linux/arm64 support would allow switching back later.

The mise.lock entries are hand-authored for all four platforms (linux-x64, linux-arm64, macos-arm64, macos-x64version_131 publishes assets for all of them). Checksums were taken from the sha256 digests GitHub displays on the release page and cross-checked against the .sha256 companion assets (they match for all four). The tarball's nested binaryen-version_131/bin/ layout is handled by mise's automatic strip_components + bin-directory detection, so wasm-opt lands on PATH via mise shims and wasm-pack finds it as before.

🔗 Related links

🔍 What does this change?

  • .config/mise/config.toml: replaces both "aqua:WebAssembly/binaryen" = "version_116" and "cargo:wasm-opt" = "0.116.1" with a single "github:WebAssembly/binaryen" = "version_131"
  • .config/mise/mise.lock: removes the cargo:wasm-opt and aqua Binaryen entries; adds github:WebAssembly/binaryen entries for linux-x64, linux-arm64, macos-arm64, and macos-x64 (URL + sha256 each)
  • apps/{hash-api,hash-frontend,hash-ai-worker-ts,hash-integration-worker}/docker/Dockerfile: swap cargo:wasm-optgithub:WebAssembly/binaryen in the mise install --locked tool list (these images build for linux/arm64, now covered by the aarch64-linux asset)
  • apps/hash-frontend/vercel-install.sh and apps/petrinaut-website/vercel-install.sh: swap aqua:WebAssembly/binaryengithub:WebAssembly/binaryen

Pre-Merge Checklist 🚀

🚢 Has this modified a publishable library?

This PR:

  • does not modify any publishable blocks or libraries, or modifications do not need publishing

📜 Does this require a change to the docs?

The changes in this PR:

  • are internal and do not require a docs change

🕸️ Does this require a change to the Turbo Graph?

The changes in this PR:

  • do not affect the execution graph

⚠️ Known issues

  • Version jump 116 → 131: the builds previously used binaryen 116 (crate 0.116.1); they now use binaryen 131. wasm-pack invokes wasm-opt identically, but the optimizer itself is 15 releases newer.
  • Renovate: the github backend tracks release tags verbatim (version_131), unlike the aqua registry's tag conversion — the renovate mise manager may need a check that it picks up version_... tags for this tool; if not, updates are a one-line manual bump.
  • The lock entries have no url_api asset-id fields (api.github.com for WebAssembly/binaryen is unreachable from the sandbox this was authored in). mise lock on a dev machine would normalize the entries if wanted — CI's mise install --locked will tell if the hand-authored form is insufficient.
  • Dev machines running a full mise install will download the Binaryen tarball (~86 MB on linux-x64, ~7 MB on macOS).

🐾 Next steps

  • Tim floated removing the "ancient wasm-setup for the type system" entirely in the Slack thread — if that lands, github:WebAssembly/binaryen and cargo:wasm-pack can be dropped altogether.
  • Optional: upstream an aqua-registry PR adding linux/arm64 (aarch64 replacement) support for binaryen ≥ 131, then switch back to aqua: for registry-managed renovate updates.

🛡 What tests cover this?

  • CI runs mise install --env ci --jobs 1 --locked on linux-x64, which installs the tool from the locked URL and verifies its checksum.
  • The four service Docker image builds run mise install --locked … github:WebAssembly/binaryen on linux/arm64, exercising the aarch64-linux lock entry.

❓ How to test this?

  1. Check the Vercel preview builds on this PR: the install phase should drop from ~9 min to ~2 min (no more cargo:wasm-opt compile).
  2. In the build log, github:WebAssembly/binaryen should install in seconds and wasm-pack builds should still find wasm-opt.
  3. Trigger a service Docker image build: the arm64 build should install Binaryen from the aarch64-linux asset instead of compiling the crate.

…alls

Every Vercel build spent ~6m54s compiling the wasm-opt crate from source
because cargo-binstall finds no prebuilt binary for it. Install wasm-opt
from the WebAssembly/binaryen release binaries (aqua backend) instead,
keeping version parity (crate 0.116.1 = binaryen version_116).

The Docker images keep cargo:wasm-opt: they build natively for
linux/arm64, where Binaryen publishes no release asset.
@vercel

vercel Bot commented Jul 27, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
hash Ready Ready Preview, Comment Jul 27, 2026 12:59pm
hashdotdesign-tokens Ready Ready Preview, Comment Jul 27, 2026 12:59pm
petrinaut Ready Ready Preview, Comment Jul 27, 2026 12:59pm

Use mise's github backend to install prebuilt Binaryen release binaries
on every platform, including linux/arm64 (aarch64-linux asset shipped
since version_131). This removes the cargo:wasm-opt crate build - the
last consumer was the Docker images - so wasm-opt is now one tool at
one version everywhere: CI, Vercel installs, and Docker image builds.

The aqua backend was considered (registry tags are renovate-friendly)
but the aqua registry does not support linux/arm64 for binaryen >= 108,
which the arm64 Docker builds need.

Lock entries are hand-authored from the release page digests and the
.sha256 companion assets (verified to match).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/apps > hash* Affects HASH (a `hash-*` app) area/apps > hash-api Affects the HASH API (app) area/apps type/eng > backend Owned by the @backend team type/eng > frontend Owned by the @frontend team

Development

Successfully merging this pull request may close these issues.

2 participants