{"record":{"id":"f464a4547da6cc50","repo":"wasmerio/wasmer","slug":"the-type-is-not-yet-supported-in-the-js-global-api","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/global.rs","lineNumber":47,"sourceCode":"        val: Value,\n        mutability: Mutability,\n    ) -> Result<Self, RuntimeError> {\n        if !val.is_from_store(store) {\n            return Err(RuntimeError::new(\n                \"cross-`WasmerEnv` values are not supported\",\n            ));\n        }\n        let global_ty = GlobalType {\n            mutability,\n            ty: val.ty(),\n        };\n        let descriptor = js_sys::Object::new();\n        let (type_str, value) = match val {\n            Value::I32(i) => (\"i32\", JsValue::from_f64(i as _)),\n            Value::I64(i) => (\"i64\", JsValue::from_f64(i as _)),\n            Value::F32(f) => (\"f32\", JsValue::from_f64(f as _)),\n            Value::F64(f) => (\"f64\", JsValue::from_f64(f)),\n            _ => unimplemented!(\"The type is not yet supported in the JS Global API\"),\n        };\n        // This is the value type as string, even though is incorrectly called \"value\"\n        // in the JS API.\n        js_sys::Reflect::set(&descriptor, &\"value\".into(), &type_str.into())?;\n        js_sys::Reflect::set(\n            &descriptor,\n            &\"mutable\".into(),\n            &mutability.is_mutable().into(),\n        )?;\n\n        let js_global = WebAssembly::Global::new(&descriptor, &value).unwrap();\n        let vm_global = VMGlobal::new(js_global, global_ty);\n\n        Ok(Self::from_vm_extern(store, VMExternGlobal::Js(vm_global)))\n    }\n\n    pub fn ty(&self, _store: &impl AsStoreRef) -> GlobalType {\n        self.handle.ty","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/wasmerio/wasmer/blob/8c4b9ee9d33fb2068863fbb3d328683e7e6ff7f5/lib/api/src/backend/js/entities/global.rs#L29-L65","documentation":"Global::from_value for the JS backend only maps I32, I64, F32, F64 to JS descriptor/value pairs; all other Value variants (e.g. V128, FuncRef, ExternRef) hit `unimplemented!`. The JS WebAssembly.Global API surface supported by this binding does not cover those types yet.","triggerScenarios":"Creating or importing a wasmer Global from a Value::V128 (SIMD) or a reference-typed value (funcref/externref) through the js backend's Global::from_value path — e.g. embedder code building globals programmatically or a wasm module exporting/importing a v128 or ref global in a browser/Node runtime.","commonSituations":"Wasm modules using reference types (reftypes) or SIMD globals compiled to run on wasmer-js; embedders passing Values other than the four numeric types when creating globals in the browser; parity gaps with the native backend.","solutions":["Restrict globals to i32/i64/f32/f64 values on the js backend","Convert reference globals to host-side storage (e.g. externref tables or host functions) instead of JS Globals","Upgrade wasmer — newer builds may map ref types to WebAssembly.Global of type funcref/externref","Add a validation step rejecting non-numeric global Values on the js backend before calling from_value"],"exampleFix":"// before\nmatch val {\n    Value::V128(_) => unimplemented!(\"...\"),\n}\n// after\nmatch val {\n    Value::V128(_) => Err(GlobalError::Unsupported(\"v128 globals are not supported on the JS backend\")),\n    _ => /* existing numeric path */,\n}","handlingStrategy":"validation","validationCode":"// validate global value type before creating a JS-backed Global\nfn global_value_js_supported(v: &Value) -> bool {\n    matches!(v, Value::I32(_) | Value::I64(_) | Value::F32(_) | Value::F64(_))\n}","typeGuard":"fn is_numeric_global_value(v: &Value) -> bool {\n    matches!(v, Value::I32(_) | Value::I64(_) | Value::F32(_) | Value::F64(_))\n}","tryCatchPattern":null,"preventionTips":["Only create i32/i64/f32/f64 globals on the js backend","Keep v128 and ref-typed values out of JS globals; use host-side storage instead","Validate Value variants at the embedder boundary before Global::new","Re-check support matrix after wasmer upgrades"],"tags":["javascript","globals","simd","reference-types"],"backgroundTag":"js-backend-unsupported-feature","analyzedSha":"8c4b9ee9d33fb2068863fbb3d328683e7e6ff7f5","analyzedAt":"2026-09-01T23:06:31.009Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}