{"record":{"id":"19dd7903921cef76","repo":"wasmerio/wasmer","slug":"the-value-is-not-yet-supported-in-the-js-fu","errorCode":null,"errorMessage":"The value `{:?}` is not yet supported in the JS Function API","messagePattern":"The value `(.+?)` 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":90,"sourceCode":"    }\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)]\n            _ => unreachable!(\"a JS function received an externref from another backend\"),\n        },\n        Value::ExternRef(None) => JsValue::null(),\n        val => unimplemented!(\n            \"The value `{:?}` is not yet supported in the JS Function API\",\n            val\n        ),\n    }\n}\n\nimpl AsJs for Value {\n    type DefinitionType = Type;\n\n    fn as_jsvalue(&self, _store: &impl AsStoreRef) -> JsValue {\n        match self {\n            Self::I32(i) => JsValue::from(*i),\n            Self::I64(i) => JsValue::from(*i),\n            Self::F32(f) => JsValue::from(*f),\n            Self::F64(f) => JsValue::from(*f),\n            Self::V128(v) => JsValue::from(*v),\n            Self::FuncRef(Some(func)) => func.as_js().handle.function.clone().into(),\n            Self::FuncRef(None) => JsValue::null(),","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/wasmerio/wasmer/blob/8c4b9ee9d33fb2068863fbb3d328683e7e6ff7f5/lib/api/src/backend/js/utils/convert.rs#L72-L108","documentation":"`wasmer_value_to_js` converts wasmer `Value`s returned to JS (e.g. from exported function results). Most types are supported, including optional externrefs, but any remaining value kind reaching the catch-all arm — such as Value::FuncRef or Value::ExceptionRef — panics with this unimplemented message.","triggerScenarios":"Calling an exported wasm function (or host function created via `new_with_env`/`new_with_env_async`) on the js backend where the result `Value` is a FuncRef or ExceptionRef (the catch-all `val =>` arm).","commonSituations":"Exports returning funcrefs to the browser; JS callers of a wasm module whose ABI includes reference-typed returns.","solutions":["Avoid exporting functions that return FuncRef/ExceptionRef on the js backend; return an i32 handle into a host registry instead","Convert funcref results inside wasm to externref(JS) values before returning","Run the module on a native backend if reference returns are required"],"exampleFix":"// before\nValue::FuncRef(f) // returned from export -> panics\n// after\nValue::I32(registry.insert(f)) // return handle, JS fetches via host call","handlingStrategy":"type-guard","validationCode":"fn js_returnable(v: &Value) -> bool {\n    !matches!(v, Value::FuncRef(_) | Value::ExceptionRef(_))\n}","typeGuard":"fn js_returnable(v: &Value) -> bool {\n    !matches!(v, Value::FuncRef(_) | Value::ExceptionRef(_))\n}","tryCatchPattern":"if !js_returnable(&result) {\n    return Err(anyhow!(\"result type not supported by js Function API\"));\n}","preventionTips":["Keep exported functions returning numeric/externref types only","Never return FuncRef/ExceptionRef from exports in browser builds","Audit module exports with Module::info or a wasm parser before deploying to JS"],"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"}