{"record":{"id":"e8db3398858e7402","repo":"wasmerio/wasmer","slug":"externref-is-not-yet-supported-in-wasm-c-api","errorCode":null,"errorMessage":"ExternRef is not yet supported in wasm_c_api","messagePattern":"ExternRef is not yet supported in wasm_c_api","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/api/src/backend/v8/entities/external.rs","lineNumber":25,"sourceCode":"\n#[derive(Debug, Clone)]\n#[repr(transparent)]\n/// A WebAssembly `extern ref` in the `v8` runtime.\npub struct ExternRef;\n\nimpl ExternRef {\n    pub fn new<T>(_store: &mut impl AsStoreMut, _value: T) -> Self\n    where\n        T: Any + Send + Sync + 'static + Sized,\n    {\n        unimplemented!(\"ExternRef is not yet supported with wasm_c_api\");\n    }\n\n    pub fn downcast<'a, T>(&self, _store: &'a impl AsStoreRef) -> Option<&'a T>\n    where\n        T: Any + Send + Sync + 'static + Sized,\n    {\n        unimplemented!(\"ExternRef is not yet supported in wasm_c_api\");\n    }\n\n    pub(crate) fn vm_externref(&self) -> VMExternRef {\n        unimplemented!(\"ExternRef is not yet supported in wasm_c_api\");\n    }\n\n    pub(crate) unsafe fn from_vm_externref(\n        _store: &mut impl AsStoreMut,\n        _vm_externref: VMExternRef,\n    ) -> Self {\n        unimplemented!(\"ExternRef is not yet supported in wasm_c_api\");\n    }\n\n    pub fn is_from_store(&self, _store: &impl AsStoreRef) -> bool {\n        true\n    }\n\n    pub fn ptr_eq(&self, _other: &Self) -> bool {","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/wasmerio/wasmer/blob/8c4b9ee9d33fb2068863fbb3d328683e7e6ff7f5/lib/api/src/backend/v8/entities/external.rs#L7-L43","documentation":"ExternRef (a host value passed into WebAssembly as an opaque reference) is not implemented in the wasm_c_api-compatible backend this build uses. The method is compiled in to satisfy the common ExternRef API surface, but panics with unimplemented!() whenever called. It signals a feature gap, not a runtime fault in your code.","triggerScenarios":"Calling ExternRef::downcast::<T>(store) on a build where the v8 backend is selected via wasm_c_api; any code path that tries to recover the host value from an ExternRef in that backend.","commonSituations":"Running wasmer with the v8/wasm_c_api backend while application code (or a guest ABI shim like WASI or component-model glue) uses externrefs; code that works on the sys/LLVM backend panics after switching backends.","solutions":["Switch to a backend that implements ExternRef (e.g. the sys/LLVM or js backend) via cargo features or engine selection","Refactor the host code to avoid externrefs (pass data via linear memory or imports instead)","Implement downcast for this backend upstream or in a fork before calling it","Guard the call behind a capability check so the code path is never reached on unsupported backends"],"exampleFix":"// before\nlet value = extern_ref.downcast::<MyData>(store).unwrap();\n// after\n// build with a backend that supports ExternRef, or:\nlet value = match backend_supports_externref() {\n    true => extern_ref.downcast::<MyData>(store).unwrap(),\n    false => panic!(\"externref unsupported on this backend; use sys backend\"),\n};","handlingStrategy":"validation","validationCode":"fn externref_supported(engine: &Engine) -> bool {\n    // ExternRef is unimplemented on wasm_c_api/v8-backed builds\n    !matches!(engine.target_backend(), Backend::WasmCApi | Backend::V8)\n}\n","typeGuard":"fn is_externref_capable(engine: &Engine) -> bool {\n    matches!(engine.backend(), Backend::Sys | Backend::Js)\n}\n","tryCatchPattern":"// unimplemented!() panics rather than returning an Err, so catch it at a boundary\nlet result = std::panic::catch_unwind(|| extern_ref.downcast::<MyData>(store).cloned());\nmatch result {\n    Ok(Some(data)) => use_data(data),\n    _ => fallback_without_externref(),\n}\n","preventionTips":["Verify backend feature flags (sys vs v8/wasm_c_api) before relying on ExternRef","Keep a matrix test of all externref APIs per backend in CI","Prefer linear-memory data passing for maximum backend portability","Document backend support requirements in your crate's README"],"tags":["wasm","externref","unimplemented","v8","backend-support"],"backgroundTag":"externref-unsupported-backend","analyzedSha":"8c4b9ee9d33fb2068863fbb3d328683e7e6ff7f5","analyzedAt":"2026-09-01T23:06:31.009Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}