wasmerio/wasmer · error · anyhow::Error

Unsupported backend type

Error message

Unsupported backend type

What it means

get_engine matches only the backend variants compiled into the current feature set (sys backends plus the v8 feature). Any other Backend value falls into the catch-all arm and bails with 'Unsupported backend type'. This occurs when a backend was compiled out of the binary via cargo feature flags or an unknown variant is constructed.

Source

Thrown at lib/cli/src/backend.rs:723

                    match p {
                        Profiler::Perfmap => config.enable_perfmap(),
                        Profiler::Gdb => config.enable_debugger(Debugger::Gdb),
                        Profiler::Lldb => config.enable_debugger(Debugger::Lldb),
                    }
                }

                let engine = wasmer_compiler::EngineBuilder::new(config)
                    .set_features(Some(supported_features))
                    .set_target(Some(target.clone()))
                    .engine()
                    .into();
                Ok(engine)
            }
            #[cfg(feature = "v8")]
            Self::V8 => Ok(wasmer::v8::V8::new().into()),
            Self::Headless => bail!("Headless is not a valid runtime to instantiate directly"),
            #[allow(unreachable_patterns)]
            _ => bail!("Unsupported backend type"),
        }
    }

    /// Check if this backend supports all the required WebAssembly features
    #[allow(unreachable_code)]
    pub fn supports_features(&self, required_features: &Features, target: &Target) -> bool {
        // Map BackendType to the corresponding wasmer::BackendKind
        let backend_kind = match self {
            #[cfg(feature = "singlepass")]
            Self::Singlepass => wasmer::BackendKind::Singlepass,
            #[cfg(feature = "cranelift")]
            Self::Cranelift => wasmer::BackendKind::Cranelift,
            #[cfg(feature = "llvm")]
            Self::LLVM => wasmer::BackendKind::LLVM,
            #[cfg(feature = "v8")]
            Self::V8 => wasmer::BackendKind::V8,
            Self::Headless => return false, // Headless can't compile
            #[allow(unreachable_patterns)]

View on GitHub (pinned to 8c4b9ee9d3)

Solutions

  1. Rebuild wasmer with the required feature enabled (e.g. cargo build --features v8, or enable cranelift/llvm/singlepass features).
  2. Pick a backend that the installed binary supports (run `wasmer config` / check available engines).
  3. If a script passes a backend name, correct the typo or stale name.

Example fix

// before (binary built without v8)
let engine = Backend::V8.get_engine()?; // Unsupported backend type
// after: rebuild
// cargo build --release --features v8
let engine = Backend::V8.get_engine()?;
Defensive patterns

Strategy: fallback

Validate before calling

fn backend_supported(b: &Backend, features: &Features) -> bool {
    b.supports_features(features, &Target::default())
}

Type guard

fn is_compiled_in(b: &Backend) -> bool {
    matches!(b, Backend::Cranelift | Backend::LLVM | Backend::Singlepass) || cfg!(feature = "v8") && matches!(b, Backend::V8)
}

Try / catch

match backend.get_engine() {
    Ok(e) => e,
    Err(e) if e.to_string() == "Unsupported backend type" => {
        eprintln!("backend {:?} unavailable in this build; falling back to cranelift", backend);
        Backend::Cranelift.get_engine()?
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Calling get_engine() on a Backend variant not enabled at compile time (e.g. requesting V8 without the 'v8' feature, or a backend like LLVM when built without it), or any exotic/unrecognized Backend value.

Common situations: Running a wasmer binary that was built without the needed feature flags; CLI --engine flag referencing a backend the build does not include; version drift where a backend name no longer exists.

Related errors


AI-assisted analysis of wasmerio/wasmer@8c4b9ee9d3 (2026-09-01). Data as JSON: /api/errors/9e3fcd5b67a887f7. Report an issue: GitHub.