wasmCloud: [BUG] http client fails if body is finished with some empty trailers

Affected project(s)

  • documentation
  • examples
  • wasmCloud host
  • wasmCloud CLI (wash)
  • wasmCloud dashboard UI (washboard)
  • capability providers
  • provider bindgen
  • control interface client
  • other / not sure

Describe the bug

The http client does not perform correctly if sending a request over HTTP/2 and if the body is finished with Some(Fields::new())

Steps to reproduce

Take the example of examples/rust/components/dog-fetcher.

Replace lines 36-38 to:

        req.set_authority(Some("api.github.com")).unwrap(); // sorry github
        req.set_path_with_query(Some("/"))
            .unwrap();
        OutgoingBody::finish(req.body().unwrap(), Some(Fields::new())).unwrap();

And run

wash build
wash up --log-level debug

In another terminal

wash app deploy ./local.wadm.yaml
curl localhost:8080

Expected behavior

I’m expected that it returns some 40x response. But here’s the actual log:

2024-09-12T02:23:33.469382Z DEBUG serve_handle: wasmcloud_provider_http_client: send HTTP request uri=https://api.github.com/
2024-09-12T02:23:33.572288Z DEBUG serve_handle:http_request: h2::client: binding client connection
2024-09-12T02:23:33.572326Z DEBUG serve_handle:http_request: h2::client: client connection bound
2024-09-12T02:23:33.572365Z DEBUG serve_handle:http_request: h2::codec::framed_write: send frame=Settings { flags: (0x0), enable_push: 0, initial_window_size: 2097152, max_frame_size: 16384, max_header_list_size: 16384 }
2024-09-12T02:23:33.572504Z DEBUG serve_handle:http_request:Connection{peer=Client}: h2::codec::framed_write: send frame=WindowUpdate { stream_id: StreamId(0), size_increment: 5177345 }
2024-09-12T02:23:33.572517Z DEBUG serve_handle:http_request:Connection{peer=Client}: h2::codec::framed_write: send frame=Headers { stream_id: StreamId(1), flags: (0x4: END_HEADERS) }
2024-09-12T02:23:33.572608Z DEBUG serve_handle:http_request:Connection{peer=Client}: h2::codec::framed_write: send frame=Headers { stream_id: StreamId(1), flags: (0x5: END_HEADERS | END_STREAM) }
2024-09-12T02:23:33.656583Z DEBUG serve_handle:http_request:Connection{peer=Client}: h2::codec::framed_read: received frame=Settings { flags: (0x0), max_concurrent_streams: 100, initial_window_size: 67108864, max_frame_size: 68608, enable_connect_protocol: 1 }
2024-09-12T02:23:33.656611Z DEBUG serve_handle:http_request:Connection{peer=Client}: h2::codec::framed_write: send frame=Settings { flags: (0x1: ACK) }
2024-09-12T02:23:33.656619Z DEBUG serve_handle:http_request:Connection{peer=Client}: h2::codec::framed_read: received frame=Settings { flags: (0x1: ACK) }
2024-09-12T02:23:33.656622Z DEBUG serve_handle:http_request:Connection{peer=Client}: h2::proto::settings: received settings ACK; applying Settings { flags: (0x0), enable_push: 0, initial_window_size: 2097152, max_frame_size: 16384, max_header_list_size: 16384 }
2024-09-12T02:23:33.656627Z DEBUG serve_handle:http_request:Connection{peer=Client}: h2::codec::framed_read: received frame=GoAway { error_code: FRAME_SIZE_ERROR, last_stream_id: StreamId(1) }
2024-09-12T02:23:33.656637Z DEBUG serve_handle:http_request:Connection{peer=Client}: h2::codec::framed_read: received frame=Reset { stream_id: StreamId(1), error_code: NO_ERROR }
2024-09-12T02:23:33.656866Z DEBUG serve_handle: wasmcloud_provider_http_client: failed to send HTTP request err=hyper_util::client::legacy::Error(SendRequest, hyper::Error(Http2, Error { kind: Reset(StreamId(1), NO_ERROR, Remote) }))

Environment

  • OS: MacOS
  • Shell: zsh
  • wasmcloud Version:
wash          v0.32.1
├ nats-server v2.10.18
├ wadm        v0.14.0
└ wasmcloud   v1.2.1

Screenshots / Logs / Additional context

Confirm with

wasmtime serve -S cli=y ./build/dog_fetcher_s.wasm

It will have

$ curl localhost:8080
HTTP request failed with status code 403%

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 17 (16 by maintainers)

Most upvoted comments

The problems I’ve encountered seems to have gone when using the canary version of httpclient, so I think this can be closed, WDYT @peter-jerry-ye ?

thanks for the tips, very helpful!

Somehow if I change the code in the provider-http-client (for example a log message) I do not see those changes reflected. Is this crate used? Do I need to do something special to recompile this?

Ah so I think you might be running into the difference between the lib crate and the bin crate – the bin crate is at the top level, you’d have to do something like this:

wash build -p src/bin/http-client-provider

That will build the new bin, making use of the updated lib crate.

I’m generally unsure about the role of wRPC. Are we running the http client in native or WASM?

The HTTP client runs in native rust code (the provider), but interfaces with the host, in a subprocess spawned by the host. wRPC is the mechanism that lets Wasm modules (spoken for by the host) and providers communicate. Provider calls/entrypoints essentially turn into functions that use wRPC to transfer values via generated code.

So when you write the impl for a generated trait in a provider, those functions are plugged into a sort of wRPC shim that does the actually communication using wRPC.

Re-opening as it seems someone else has run into this – probably worth testing with 204 responses explicitly in the provider!