Skip to content
Latchkey

Fastly Compute "fastly compute build" Wasm failure in CI

Fastly Compute compiles your application to a WebAssembly module using the build command in fastly.toml. When that build script fails, or the language toolchain (Rust, JS) is not present, fastly compute build exits before producing the .wasm package.

What this error means

The CI step fails with "Error: error building project" or "The [scripts.build] command terminated with a non-zero exit code". No package.tar.gz is produced for deploy.

Fastly
Error: error building project with build command.

  Caused by:
    The `[scripts.build]` command terminated with a non-zero exit code.

Common causes

The build command fails or the toolchain is missing

The [scripts.build] command in fastly.toml depends on a compiler or bundler (cargo, npm) that errored or is not installed on the runner.

The wasm32 target is not installed

For Rust Compute projects, the wasm32-wasi target must be added; without it cargo cannot produce the Wasm module.

How to fix it

Provision the toolchain before building

  1. Install the language toolchain the build command needs on the runner.
  2. For Rust, add the wasm target.
  3. Re-run fastly compute build so the build script succeeds.
Terminal
rustup target add wasm32-wasi
fastly compute build

Reproduce the build command directly

Run the exact [scripts.build] command from fastly.toml to see the underlying compiler error, then fix that.

fastly.toml
# fastly.toml
[scripts]
build = "npm run build"

How to prevent it

  • Install the language toolchain and wasm target as an explicit CI step.
  • Run the build command directly to surface compiler errors.
  • Pin toolchain versions so the Wasm build is reproducible.

Frequently asked questions

What causes ""fastly compute build" failed"?
The [scripts.build] command in fastly.toml depends on a compiler or bundler (cargo, npm) that errored or is not installed on the runner.
How do I fix "fastly compute build" failed?
Provision the toolchain before building

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card