{"record":{"id":"b5a19d952ea0b4c9","repo":"wasmerio/wasmer","slug":"the-type-is-not-yet-supported-in-the-js-global-api-b5a19d","errorCode":null,"errorMessage":"The type is not yet supported in the JS Global API","messagePattern":"The type is not yet supported in the JS Global API","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/api/src/backend/js/entities/tag.rs","lineNumber":33,"sourceCode":"unsafe impl Send for Tag {}\nunsafe impl Sync for Tag {}\n\n// Tag can't be Send in js because it doesn't support `structuredClone`\n// https://developer.mozilla.org/en-US/docs/Web/API/structuredClone\n// unsafe impl Send for Tag {}\n\nimpl Tag {\n    pub fn new<P: Into<Box<[Type]>>>(store: &mut impl AsStoreMut, params: P) -> Self {\n        let descriptor = js_sys::Object::new();\n        let params: Box<[Type]> = params.into();\n        let parameters: Vec<String> = params\n            .iter()\n            .map(|param| match param {\n                Type::I32 => \"i32\".to_string(),\n                Type::I64 => \"i64\".to_string(),\n                Type::F32 => \"f32\".to_string(),\n                Type::F64 => \"f64\".to_string(),\n                _ => unimplemented!(\"The type is not yet supported in the JS Global API\"),\n            })\n            .collect();\n        js_sys::Reflect::set(&descriptor, &\"parameters\".into(), &parameters.into()).unwrap();\n\n        let tag = js_sys::WebAssembly::Tag::new(&descriptor);\n        let ty = TagType::new(TagKind::Exception, params);\n        let handle = VMTag::new(tag.unwrap(), ty);\n        Self { handle }\n    }\n\n    pub fn ty(&self, store: &impl AsStoreRef) -> TagType {\n        self.handle.ty.clone()\n    }\n\n    pub(crate) fn from_vm_extern(store: &mut impl AsStoreMut, vm_extern: VMExternTag) -> Self {\n        Self {\n            handle: vm_extern.unwrap_js(),\n        }","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/wasmerio/wasmer/blob/8c4b9ee9d33fb2068863fbb3d328683e7e6ff7f5/lib/api/src/backend/js/entities/tag.rs#L15-L51","documentation":"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.","triggerScenarios":"Calling `Tag::new(store, TagType::new(kind, params), ...)` on the js backend where `params` contains any type other than I32, I64, F32, or F64.","commonSituations":"Defining exception tags that pass references (externref/funcref) as payloads; browser exception-handling experiments with reference-typed payloads.","solutions":["Restrict tag payload types to the four numeric wasm types","Encode reference payloads as i32 handles/indexes into a host-side table","Fall back to a native backend (sys) if reference-typed exception payloads are required"],"exampleFix":"// before\nlet ty = TagType::new(TagKind::Exception, vec![Type::ExternRef]);\n// after\nlet ty = TagType::new(TagKind::Exception, vec![Type::I32]); // pass handle instead","handlingStrategy":"validation","validationCode":"fn tag_params_supported(params: &[Type]) -> bool {\n    params.iter().all(|t| matches!(t, Type::I32 | Type::I64 | Type::F32 | Type::F64))\n}","typeGuard":null,"tryCatchPattern":"assert!(tag_params_supported(&params), \"js Tag supports only i32/i64/f32/f64 params\");\nlet tag = Tag::new(&mut store, TagType::new(TagKind::Exception, params));","preventionTips":["Validate exception tag parameter types before Tag::new on js builds","Encode reference payloads as i32 handles","Keep wasm exception usage behind a feature flag"],"tags":["wasm","javascript-backend","exceptions","tag","unimplemented"],"backgroundTag":"unimplemented-js-backend-feature","analyzedSha":"8c4b9ee9d33fb2068863fbb3d328683e7e6ff7f5","analyzedAt":"2026-09-01T23:06:31.009Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}