wasmerio/wasmer · error

module info requires the wasm-types-polyfill feature

Error message

module info requires the wasm-types-polyfill feature

What it means

`Module::info()` returns the internal wasm module metadata, but on the JS backend that information is only populated when the `wasm-types-polyfill` cargo feature is enabled. Without it, `info()` panics with this unimplemented stub.

Source

Thrown at lib/api/src/backend/js/entities/module.rs:608

            WebAssembly::Module::custom_sections(&self.module, name)
                .iter()
                .map(move |buf_val| {
                    let typebuf: js_sys::Uint8Array = js_sys::Uint8Array::new(&buf_val);
                    typebuf.to_vec().into_boxed_slice()
                })
                .collect::<Vec<Box<[u8]>>>()
                .into_iter(),
        )
    }

    pub(crate) fn info(&self) -> &ModuleInfo {
        #[cfg(feature = "wasm-types-polyfill")]
        {
            &self.info
        }
        #[cfg(not(feature = "wasm-types-polyfill"))]
        {
            unimplemented!("module info requires the wasm-types-polyfill feature")
        }
    }
}

impl From<WebAssembly::Module> for Module {
    #[track_caller]
    fn from(module: WebAssembly::Module) -> Self {
        Self {
            module: JsHandle::new(module),
            name: None,
            type_hints: None,
            #[cfg(feature = "wasm-types-polyfill")]
            info: ModuleInfo::default(),
            #[cfg(feature = "js-serializable-module")]
            raw_bytes: None,
        }
    }
}

View on GitHub (pinned to 8c4b9ee9d3)

Solutions

  1. Enable the feature: `wasmer = { version = "...", features = ["js", "wasm-types-polyfill"] }`
  2. Avoid `Module::info()` in browser code; parse imports/exports with `web-sys`/`js_sys::WebAssembly::Module::imports/exports` directly
  3. Compile the polyfill feature in only for the code path that needs module metadata

Example fix

// before (Cargo.toml)
wasmer = { version = "4", features = ["js"] }
// after
wasmer = { version = "4", features = ["js", "wasm-types-polyfill"] }
Defensive patterns

Strategy: validation

Validate before calling

// build-time check in build.rs or a test:
// #[cfg(all(feature = "js", not(feature = "wasm-types-polyfill")))]
// compile_error!("Module::info requires the wasm-types-polyfill feature");

Type guard

fn module_info_available() -> bool {
    cfg!(feature = "wasm-types-polyfill")
}

Try / catch

if module_info_available() {
    let info = module.info(&store);
} else {
    // fall back to js_sys::WebAssembly module inspection
}

Prevention

When it happens

Trigger: Calling `Module::info(&store)` on the js backend while the `wasm-types-polyfill` feature of the wasmer crate is not enabled in Cargo.toml.

Common situations: Code that inspects imports/exports/datas of a module compiled in the browser; the feature is off by default and easy to miss when enabling the `js` backend.

Related errors


AI-assisted analysis of wasmerio/wasmer@8c4b9ee9d3 (2026-09-01). Data as JSON: /api/errors/b5b8d3a67c05b7a6. Report an issue: GitHub.