Skip to content

wasi:http bleeding into the preview1 adapter #7266

Closed

Description

@rvolosatovs

Test Case

https://github.com/rvolosatovs/wasmtime-adapter-http-repro

Steps to Reproduce

Expected Results

Success, especially because wasm-tools print suggests no incoming-body type exists in the adapter

Actual Results

Failure to encode a component

Versions and Environment

dev (9e4d446)

Operating system: linux

Architecture: x86_64

Extra Info

We have seen this issue before @dicej @alexcrichton @pchickey, it appeared that it was fixed, but perhaps that was because the component and adapter definitions happened to be in sync during testing.

Activity

  1. added
    bug
    on Oct 17, 2023
  2. changed the title [-]`wasi:http` bleeding into the preview2 adapter[/-] [+]`wasi:http` bleeding into the preview1 adapter[/+] on Oct 17, 2023
  3. alexcrichton commented on Oct 17, 2023

    @alexcrichton
    Member

    Looking into this the issue appears to be:

    • The Resolve for the world used to create the adapter has wasi:http in it. This is because the wasmtime:wasi package that's used to pull everything together has worlds in it that depend on wasi:http.
    • When the adapter is produced the wasmtime:wasi package is serialized into binary and embedded within the adapter itself.
    • When the adapter is processed by wit-component it will deserialize this information into an entire Resolve and then merge it with the target resolve.

    This means that even though the adapter itself doesn't use the wasi:http interfaces the merge step of two Resolve items still attempts to merge them together. The best fix that I can think of is to filter out items during the encoding phase so only the relevant types are encoded, namely just the wasmtime:wasi/preview1-adapter-reactor world for example. Such filtering should remove the encoding of wasi:http types and interfaces, meaning they'll be entirely gone from the adapter.

    Such a change must happen in wit-component in the wasm-tools repository. I'll wait for bytecodealliance/wasm-tools#1252 to finish before implementing this.

  4. added a commit that references this issue on Oct 20, 2023
  5. alexcrichton commented on Oct 20, 2023

    @alexcrichton
    Member

    Ok I've looked again at this and this should be solved by bytecodealliance/wasm-tools#1260. The issue doesn't actually reproduce as-is today due to the introduction of versions on main which means merging now succeeds, but I've tested main just before versions came in and was able to reproduce this issue and test that bytecodealliance/wasm-tools#1260 fixes things.

    The fix there will be a bit delayed due to the fact that we'll have it off-by-default for a bit. Eventually down the road we'll switch the adapter to using the new metadata format by default, but until that point this bug will still be present. You can compile your own adapter, however, and specify WIT_COMPONENT_NEW_ENCODE=1 to build an adapter with the new format to fix this issue. This does depend on all pices of the system using an updated wit-component, however.

  6. alexcrichton commented on Mar 26, 2024

    @alexcrichton
    Member

    I believe this has since been fixed, so closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions