I ran into this issue with a component that was importing wasi:io/poll@0.2.12.
wasi:io/poll is already imported via the call to add_to_linker_async.
define_unknown_imports_as_traps should skip already-imported instances, but it appears not to.
This example code is similar to where I experienced the error:
async fn example(component: &[u8]) -> anyhow::Result<()> {
let engine = Engine::default();
let mut linker: component::Linker<()> = component::Linker::new(&engine);
wasmtime_wasi::p2::add_to_linker_async(&mut linker)?;
// assume component imports `wasi:io/poll
let component = Component::new(&engine, component)?;
// errors
linker.define_unknown_imports_as_traps(&component)?;
Ok(())
}
Test Case
example.wat
(component
(import "wasi:io/poll@0.2.12" (instance
(export "pollable" (type (sub resource)))
))
)
Steps to Reproduce
wasmtime run -W unknown-imports-trap example.wat
Expected Results
The command fails with no exported instance named.
Error: failed to run main module `example.wat`
Caused by:
no exported instance named `wasi:io/poll@0.2.12`
Actual Results
The command fails with a defined twice.
Error: failed to run main module `example.wat`
Caused by:
map entry `wasi:io/poll@0.2.12` defined twice
Versions and Environment
Wasmtime version or commit: wasmtime 46.0.1 (823d1b8 2026-06-24)
Operating system: macOS 26.5.2
Architecture: arm64
Extra Info
The naive example above is an attempt to recreate the error I experienced in Rust.
I hope it captures the problem I experienced and isn't a distraction. If it doesn't make sense, I can attempt to provide a better example.
I ran into this issue with a component that was importing
wasi:io/poll@0.2.12.wasi:io/pollis already imported via the call to add_to_linker_async.define_unknown_imports_as_traps should skip already-imported instances, but it appears not to.
This example code is similar to where I experienced the error:
Test Case
example.watSteps to Reproduce
wasmtime run -W unknown-imports-trap example.watExpected Results
The command fails with
no exported instance named.Actual Results
The command fails with a
defined twice.Versions and Environment
Wasmtime version or commit: wasmtime 46.0.1 (823d1b8 2026-06-24)
Operating system: macOS 26.5.2
Architecture: arm64
Extra Info
The naive example above is an attempt to recreate the error I experienced in Rust.
I hope it captures the problem I experienced and isn't a distraction. If it doesn't make sense, I can attempt to provide a better example.