{"record":{"id":"fe83cc754e9c4807","repo":"wasmerio/wasmer","slug":"table-copy-is-not-natively-supported-in-javascript","errorCode":null,"errorMessage":"Table.copy is not natively supported in Javascript","messagePattern":"Table\\.copy is not natively supported in Javascript","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/api/src/backend/js/entities/table.rs","lineNumber":146,"sourceCode":"        delta: u32,\n        init: Value,\n    ) -> Result<u32, RuntimeError> {\n        let initial_value = get_table_item(store, init)?;\n        self.handle\n            .table\n            .grow_with_value(delta, initial_value)\n            .map_err(Into::into)\n    }\n\n    pub fn copy(\n        _store: &mut impl AsStoreMut,\n        _dst_table: &Self,\n        _dst_index: u32,\n        _src_table: &Self,\n        _src_index: u32,\n        _len: u32,\n    ) -> Result<(), RuntimeError> {\n        unimplemented!(\"Table.copy is not natively supported in Javascript\");\n    }\n\n    pub(crate) fn from_vm_extern(_store: &mut impl AsStoreMut, vm_extern: VMExternTable) -> Self {\n        Self {\n            handle: vm_extern.unwrap_js(),\n        }\n    }\n\n    pub fn is_from_store(&self, _store: &impl AsStoreRef) -> bool {\n        true\n    }\n}\n\nimpl crate::Table {\n    /// Consume [`self`] into [`crate::backend::js::table::Table`].\n    pub fn into_js(self) -> crate::backend::js::table::Table {\n        match self.0 {\n            BackendTable::Js(s) => s,","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/wasmerio/wasmer/blob/8c4b9ee9d33fb2068863fbb3d328683e7e6ff7f5/lib/api/src/backend/js/entities/table.rs#L128-L164","documentation":"`Table::copy` on the JS backend is a stub: the WebAssembly `table.copy` instruction is not exposed through the JS API surface used by wasmer, so calling copy panics instead of copying elements.","triggerScenarios":"Calling `Table::copy(&mut store, dst_table, dst_index, src_table, src_index, len)` in code compiled with the `js` backend.","commonSituations":"Host code that compacts/rearranges table entries, or module trap recovery that copies table regions; runs fine natively, panics in the browser build.","solutions":["Implement the copy manually: loop over `get`/`set` for the index range (only viable for externref tables on the js backend)","Recompile the guest to avoid `table.copy`, or run that module on a native backend","Skip the call behind a backend/runtime capability check"],"exampleFix":"// before\ntable.copy(&mut store, &dst, dst_i, &src, src_i, len)?;\n// after\nfor k in 0..len {\n    let v = src.get(&mut store, src_i + k)?;\n    dst.set(&mut store, dst_i + k, v)?;\n}","handlingStrategy":"validation","validationCode":"// Avoid calling Table::copy on js backend; detect at compile time\n#[cfg(target_arch = \"wasm32\")]\nfn table_copy(...) -> Result<(), RuntimeError> { /* element-wise loop */ }","typeGuard":"fn table_copy_supported() -> bool {\n    cfg!(not(target_arch = \"wasm32\"))\n}","tryCatchPattern":"if table_copy_supported() {\n    table.copy(&mut store, &dst, di, &src, si, len)?;\n} else {\n    for k in 0..len { /* get/set loop */ }\n}","preventionTips":["Never assume Table::copy exists on the js backend; wrap in a capability helper","Prefer element-wise copy loops for externref tables","Run wasm32 CI builds to catch unsupported-intrinsic usage"],"tags":["wasm","javascript-backend","table","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"}