bytecodealliance / bytecodealliance/wasm-tools
wasm-compose: Surprising behavior from instantiation pointing at undefined instance
- Dominant language
- Rust
- Stars
- 1.8k
- Forks
- 351
- Avg merge
- 16h 57m
- Merged PRs (30d)
- 38
Description
I'm working on a PoC of composing components where two components (parent and child) receive two different instances of the same imported interface. In the example I'm attempting this with wasi stdout:
```yaml
dependencies:
"component:printer/printer": child-component.wasm
instantiations:
$input:
arguments:
"wasi:cli/stdout@0.2.0-rc-2023-11-10":
instance: "isolated-stdout-parent"
"component:printer/printer":
dependency: "component:printer/printer"
arguments:
"wasi:cli/stdout@0.2.0-rc-2023-11-10":
instance: "isolated-stdout-child"
```
```console
$ wasm-tools compose -c compose.yaml parent-component.wasm -o composed.wasm
[2023-11-21T22:06:52Z WARN ] instance `wasi:io/error@0.2.0-rc-2023-11-10` will be imported because a dependency named `wasi:io/error@0.2.0-rc-2023-11-10` could not be found
...[SNIP]...
[2023-11-21T22:06:52Z WARN ] instance `wasi:cli/stdin@0.2.0-rc-2023-11-10` will be imported because a dependency named `wasi:cli/stdin@0.2.0-rc-2023-11-10` could not be found
[2023-11-21T22:06:52Z WARN ] instance `isolated-stdout-parent` will be imported because a dependency named `isolated-stdout-parent` could not be found
...[SNIP]...
[2023-11-21T22:06:52Z WARN ] instance `wasi:cli/stdin@0.2.0-rc-2023-11-10` will be imported because a dependency named `wasi:cli/stdin@0.2.0-rc-2023-11-10` could not be found
[2023-11-21T22:06:52Z WARN ] instance `isolated-stdout-child` will be imported because a dependency named `isolated-stdout-child` could not be found
...[SNIP]...
```
(notably `wasi:cli/stdout` does _not_ appear in this output)
These logs suggested that I was getting exactly what I was hoping to get: a composed component with `isolated-stdout-{parent,child}` imports (which a custom host impl would fulfill). Unfortunately, the actual `composed.wasm` does not appear as the output suggests:
```console
$ wasm-tools component wit composed.wasm
...[SNIP]...
import wasi:cli/stdout@0.2.0-rc-2023-11-10;
...[SNIP]...
```
(no references to `isolated-stdout-*`; confirmed with `wasm-tools dump`)
It seems like the given configuration should _either_ do what I expected (and the logging suggested) _or_ bail out completely.
Contributor guide
Assessment
This issue has not been assessed yet.