{"record":{"id":"3270491de018530b","repo":"wasmerio/wasmer","slug":"the-type-is-not-yet-supported-in-the-js-fun","errorCode":null,"errorMessage":"The type `{:?}` is not yet supported in the JS Function API","messagePattern":"The type `(.+?)` is not yet supported in the JS Function API","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/api/src/backend/js/utils/convert.rs","lineNumber":68,"sourceCode":"        Type::F32 => Value::F32(js_val.as_f64().unwrap() as _),\n        Type::F64 => Value::F64(js_val.as_f64().unwrap()),\n        Type::V128 => {\n            let big_num: u128 = js_sys::BigInt::from(js_val.clone()).try_into().unwrap();\n            Value::V128(big_num)\n        }\n        Type::ExternRef => {\n            if js_val.is_null() {\n                Value::ExternRef(None)\n            } else {\n                Value::ExternRef(Some(crate::ExternRef(crate::BackendExternRef::Js(\n                    crate::backend::js::entities::external::ExternRef::from_js_value(\n                        store,\n                        js_val.clone(),\n                    ),\n                ))))\n            }\n        }\n        Type::FuncRef | Type::ExceptionRef => unimplemented!(\n            \"The type `{:?}` is not yet supported in the JS Function API\",\n            ty\n        ),\n    }\n}\n\n#[inline]\n/// Convert a wasmer Value into a JsValue\npub fn wasmer_value_to_js(val: &Value) -> JsValue {\n    match val {\n        Value::I32(i) => JsValue::from_f64(*i as _),\n        Value::I64(i) => JsValue::from_f64(*i as _),\n        Value::F32(f) => JsValue::from_f64(*f as _),\n        Value::F64(f) => JsValue::from_f64(*f),\n        Value::V128(f) => JsValue::from_f64(*f as _),\n        Value::ExternRef(Some(reference)) => match &reference.0 {\n            crate::BackendExternRef::Js(reference) => reference.as_js_value(),\n            #[allow(unreachable_patterns)]","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/wasmerio/wasmer/blob/8c4b9ee9d33fb2068863fbb3d328683e7e6ff7f5/lib/api/src/backend/js/utils/convert.rs#L50-L86","documentation":"`js_value_to_wasmer` converts JS values into wasmer `Value`s when calling imported JS functions from wasm. `FuncRef` and `ExceptionRef` parameter/result types have no conversion implemented on the JS backend, so encountering one panics with this message.","triggerScenarios":"Calling (sync or async) a JS-function import whose signature includes `Type::FuncRef` or `Type::ExceptionRef` parameters or results — via `Function::new_with_env`, `new_with_env_async`, or `Function::call`/`call_async` on the js backend.","commonSituations":"Imports that pass callbacks (funcref) into JS or return exceptionrefs; works with native runtimes, panics when the same module runs in the browser.","solutions":["Change import signatures to avoid FuncRef/ExceptionRef at the JS boundary (pass numeric indices/handles instead)","Wrap the JS side so functions are exchanged through a host-side registry keyed by i32","Use a native backend if funcref-typed imports are a hard requirement"],"exampleFix":"// before\nlet ty = FunctionType::new(vec![Type::FuncRef], vec![]);\n// after\nlet ty = FunctionType::new(vec![Type::I32], vec![]); // pass funcref as registry index","handlingStrategy":"validation","validationCode":"fn js_function_sig_supported(ft: &FunctionType) -> bool {\n    ft.params().iter().chain(ft.results()).all(\n        |t| !matches!(t, Type::FuncRef | Type::ExceptionRef))\n}","typeGuard":null,"tryCatchPattern":"if !js_function_sig_supported(&func_ty) {\n    return Err(anyhow!(\"funcref/exceptionref not supported by js Function API\"));\n}\nlet f = Function::new_with_env(&mut store, &import_ty, env, callback);","preventionTips":["Check import/export signatures for FuncRef/ExceptionRef before creating JS functions","Pass functions as i32 registry handles across the JS boundary","Add a schema check for module imports when targeting the browser"],"tags":["wasm","javascript-backend","funcref","exceptionref","type-conversion"],"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"}