wasmerio/wasmer · error

The type is not yet supported in the JS Global API

Error message

The type is not yet supported in the JS Global API

What it means

When creating an Exception `Tag` on the JS backend, the tag's parameter types are mapped to WebAssembly exception-handling descriptor strings. Only I32/I64/F32/F64 are mapped; any other parameter type (e.g. externref, funcref, v128) hits `unimplemented!` and panics.

Source

Thrown at lib/api/src/backend/js/entities/tag.rs:33

unsafe impl Send for Tag {}
unsafe impl Sync for Tag {}

// Tag can't be Send in js because it doesn't support `structuredClone`
// https://developer.mozilla.org/en-US/docs/Web/API/structuredClone
// unsafe impl Send for Tag {}

impl Tag {
    pub fn new<P: Into<Box<[Type]>>>(store: &mut impl AsStoreMut, params: P) -> Self {
        let descriptor = js_sys::Object::new();
        let params: Box<[Type]> = params.into();
        let parameters: Vec<String> = params
            .iter()
            .map(|param| match param {
                Type::I32 => "i32".to_string(),
                Type::I64 => "i64".to_string(),
                Type::F32 => "f32".to_string(),
                Type::F64 => "f64".to_string(),
                _ => unimplemented!("The type is not yet supported in the JS Global API"),
            })
            .collect();
        js_sys::Reflect::set(&descriptor, &"parameters".into(), &parameters.into()).unwrap();

        let tag = js_sys::WebAssembly::Tag::new(&descriptor);
        let ty = TagType::new(TagKind::Exception, params);
        let handle = VMTag::new(tag.unwrap(), ty);
        Self { handle }
    }

    pub fn ty(&self, store: &impl AsStoreRef) -> TagType {
        self.handle.ty.clone()
    }

    pub(crate) fn from_vm_extern(store: &mut impl AsStoreMut, vm_extern: VMExternTag) -> Self {
        Self {
            handle: vm_extern.unwrap_js(),
        }

View on GitHub (pinned to 8c4b9ee9d3)

Solutions

  1. Restrict tag payload types to the four numeric wasm types
  2. Encode reference payloads as i32 handles/indexes into a host-side table
  3. Fall back to a native backend (sys) if reference-typed exception payloads are required

Example fix

// before
let ty = TagType::new(TagKind::Exception, vec![Type::ExternRef]);
// after
let ty = TagType::new(TagKind::Exception, vec![Type::I32]); // pass handle instead
Defensive patterns

Strategy: validation

Validate before calling

fn tag_params_supported(params: &[Type]) -> bool {
    params.iter().all(|t| matches!(t, Type::I32 | Type::I64 | Type::F32 | Type::F64))
}

Try / catch

assert!(tag_params_supported(&params), "js Tag supports only i32/i64/f32/f64 params");
let tag = Tag::new(&mut store, TagType::new(TagKind::Exception, params));

Prevention

When it happens

Trigger: Calling `Tag::new(store, TagType::new(kind, params), ...)` on the js backend where `params` contains any type other than I32, I64, F32, or F64.

Common situations: Defining exception tags that pass references (externref/funcref) as payloads; browser exception-handling experiments with reference-typed payloads.

Related errors


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