alexcrichton opened issue #14227:
This input:
use anyhow::Context as _; use futures::join; use std::io::{self, Read}; use test_programs::p3::wasi::http::client; use test_programs::p3::wasi::http::types::{ Headers, Method, Request, RequestOptions, Response, Scheme, }; use test_programs::p3::{wit_future, wit_stream}; struct Component; test_programs::p3::export!(Component); impl test_programs::p3::exports::wasi::cli::run::Guest for Component { async fn run() -> Result<(), ()> { const LEN: usize = 1 << 20; let body = vec![1; LEN]; let addr = test_programs::p3::wasi::cli::environment::get_environment() .into_iter() .find_map(|(k, v)| k.eq("HTTP_SERVER").then_some(v)) .unwrap(); let headers = Headers::from_list(&[]).unwrap(); let (mut contents_tx, contents_rx) = wit_stream::new(); let (trailers_tx, trailers_rx) = wit_future::new(|| Ok(None)); drop(trailers_tx); let options = RequestOptions::new(); let (request, transmit) = Request::new(headers, Some(contents_rx), trailers_rx, Some(options)); request.set_method(&Method::Post).unwrap(); request.set_scheme(Some(&Scheme::Http)).unwrap(); request.set_authority(Some(&addr)).unwrap(); request.set_path_with_query(Some("/post")).unwrap(); drop(transmit); let ((), echoed) = join!( async { let remaining = contents_tx.write_all((&body[..]).into()).await; assert!(remaining.is_empty()); drop(contents_tx); }, async { let response = client::send(request).await.context("send failed").unwrap(); let status = response.get_status_code(); assert_eq!(status, 200); let (_, result_rx) = wit_future::new(|| Ok(())); let (body_rx, _trailers_rx) = Response::consume_body(response, result_rx); body_rx.collect().await }, ); assert_eq!( echoed.len(), LEN, "response body was truncated after dropping the transmit future" ); Ok(()) } } fn main() {}tested with:
diff --git a/crates/wasi-http/tests/all/p3/mod.rs b/crates/wasi-http/tests/all/p3/mod.rs index 1fc17440f9..3b30567446 100644 --- a/crates/wasi-http/tests/all/p3/mod.rs +++ b/crates/wasi-http/tests/all/p3/mod.rs @@ -946,3 +946,9 @@ async fn p3_http_outbound_request_chunk_size() -> Result<()> { let server = Server::http1(1)?; run_cli(P3_HTTP_OUTBOUND_REQUEST_CHUNK_SIZE_COMPONENT, &server).await } + +#[test_log::test(tokio::test(flavor = "multi_thread"))] +async fn p3_http_drop_transmit() -> Result<()> { + let server = Server::http1(1)?; + run_cli(P3_HTTP_DROP_TRANSMIT_COMPONENT, &server).await +}yields:
<details>
Compiling test-programs-artifacts v0.0.0 (/home/alex/code/wasmtime2/crates/test-programs/artifacts) Compiling wasmtime-wasi-http v49.0.0-dev (/home/alex/code/wasmtime2/crates/wasi-http) Finished `test` profile [unoptimized + debuginfo] target(s) in 9.08s Running unittests src/lib.rs (target/debug/deps/wasmtime_wasi_http-65e7d209d05ca930) running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 10 filtered out; finished in 0.00s Running tests/all/main.rs (target/debug/deps/all-ccf405becb83689e) running 1 test thread '<unnamed>' (1) panicked at crates/test-programs/src/bin/p3_http_drop_transmit.rs:56:9: assertion `left == right` failed: response body was truncated after dropping the transmit future left: 8025 right: 1048576 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace test p3::p3_http_drop_transmit ... FAILED failures: ---- p3::p3_http_drop_transmit stdout ---- 2026-08-28T19:38:21.167664Z WARN all::http_server: failed to serve connection i=0 err=error writing a body to connection Error: failed to call `wasi:cli/run#run` Caused by: 0: error while executing at wasm backtrace: 0: 0x4fdc2 - abort at wasisdk://v33.0+m/build/sysroot/wasi-libc-wasm32-wasip1-build-prefix/src/wasi-libc-wasm32-wasip1-build-build/wasisdk://v33.0+m/src/wasi-libc/libc-bottom-half/sources/abort.c:5:3 1: 0x4729a - std[bc29ef7725180ca4]::sys::pal::wasi::abort_internal at /rustc/88d9e12ae178fab0fb5cc050a94da85685d449ea/library/std/src/sys/pal/wasi/mod.rs:27:14 2: 0x44ee0 - std[bc29ef7725180ca4]::process::abort at /rustc/88d9e12ae178fab0fb5cc050a94da85685d449ea/library/std/src/process.rs:2638:5 3: 0x455d7 - __rustc[4b1ee1ef74718a7b]::__rust_abort at /rustc/88d9e12ae178fab0fb5cc050a94da85685d449ea/library/std/src/rt.rs:33:5 4: 0x43bff - __rustc[4b1ee1ef74718a7b]::__rust_start_panic at /rustc/88d9e12ae178fab0fb5cc050a94da85685d449ea/library/panic_abort/src/lib.rs:50:5 5: 0x4546e - __rustc[4b1ee1ef74718a7b]::rust_panic at /rustc/88d9e12ae178fab0fb5cc050a94da85685d449ea/library/std/src/panicking.rs:887:25 6: 0x44928 - std[bc29ef7725180ca4]::panicking::panic_with_hook at /rustc/88d9e12ae178fab0fb5cc050a94da85685d449ea/library/std/src/panicking.rs:840:5 7: 0x4458f - std[bc29ef7725180ca4]::panicking::panic_handler::{closure#0} at /rustc/88d9e12ae178fab0fb5cc050a94da85685d449ea/library/std/src/panicking.rs:688:13 8: 0x444f7 - std[bc29ef7725180ca4]::sys::backtrace::__rust_end_short_backtrace::<std[bc29ef7725180ca4]::panicking::panic_handler::{closure#0}, !> at /rustc/88d9e12ae178fab0fb5cc050a94da85685d449ea/library/std/src/sys/backtrace.rs:182:18 9: 0x456ba - __rustc[4b1ee1ef74718a7b]::rust_begin_unwind at /rustc/88d9e12ae178fab0fb5cc050a94da85685d449ea/library/std/src/panicking.rs:679:5 10: 0x53c89 - core[207ea530fe29b66a]::panicking::panic_fmt at /rustc/88d9e12ae178fab0fb5cc050a94da85685d449ea/library/core/src/panicking.rs:80:14 11: 0x537c3 - core[207ea530fe29b66a]::panicking::assert_failed_inner at /rustc/88d9e12ae178fab0fb5cc050a94da85685d449ea/library/core/src/panicking.rs:434:23 12: 0x5385a - core[207ea530fe29b66a]::panicking::assert_failed::<usize, usize> at /rustc/88d9e12ae178fab0fb5cc050a94da85685d449ea/library/core/src/panicking.rs:394:5 13: 0x3953 - <p3_http_drop_transmit[dd4cfef12b085f04]::Component as test_programs[6528a46e635fc4bb]::p3::exports::wasi::cli::run::Guest>::run::{closure#0} at /home/alex/code/wasmtime2/crates/test-programs/src/bin/p3_http_drop_transmit.rs:56:9 14: 0x3b32 - test_programs[6528a46e635fc4bb]::p3::exports::wasi::cli::run::_export_run_cabi::<p3_http_drop_transmit[dd4cfef12b085f04]::Component>::{closure#0} at /home/alex/code/wasmtime2/crates/test-programs/src/p3/mod.rs:4:1 15: 0x34378 - <core[207ea530fe29b66a]::pin::Pin<alloc[abfb239ceb7de59d]::boxed::Box<dyn core[207ea530fe29b66a]::future::future::Future<Output = ()>>> as core[207ea530fe29b66a]::future::future::Future>::poll at /home/alex/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/future/future.rs:133:9 - <futures_util[1c5cead8f231934d]::stream::futures_unordered::FuturesUnordered<core[207ea530fe29b66a]::pin::Pin<alloc[abfb239ceb7de59d]::boxed::Box<dyn core[207ea530fe29b66a]::future::future::Future<Output = ()>>>> as futures_core[929563e02d1dc578]::stream::Stream>::poll_next at /home/alex/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/futures-util-0.3.31/src/stream/futures_unordered/mod.rs:528:24 16: 0x36dba - <futures_util[1c5cead8f231934d]::stream::futures_unordered::FuturesUnordered<core[207ea530fe29b66a]::pin::Pin<alloc[abfb239ceb7de59d]::boxed::Box<dyn core[207ea530fe29b66a]::future::future::Future<Output = ()>>>> as futures_util[1c5cead8f231934d]::stream::stream::StreamExt>::poll_next_unpin at /home/alex/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/futures-util-0.3.31/src/stream/stream/mod.rs:1638:24 - <wit_bindgen[bc7f8915fbd6868b]::rt::async_support::spawn::Tasks>::poll_next at /home/alex/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/wit-bindgen-0.61.1/src/rt/async_support/spawn.rs:34:35 - <wit_bindgen[bc7f8915fbd6868b]::rt::async_support::TaskState>::callback::{closure#0} at /home/alex/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/wit-bindgen-0.61.1/src/rt/async_support.rs:237:37 - <wit_bindgen[bc7f8915fbd6868b]::rt::async_support::TaskState>::with_p3_task_set::<wit_bindgen[bc7f8915fbd6868b]::rt::async_support::CallbackCode, <wit_bindgen[bc7f8915fbd6868b]::rt::async_support::TaskState>::callback::{closure#0}> at /home/alex/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/wit-bindgen-0.61.1/src/rt/async_support.rs:346:9 - <wit_bindgen[bc7f8915fbd6868b]::rt::async_support::TaskState>::callback at /home/alex/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/wit-bindgen-0.61.1/src/rt/async_support.rs:202:14 17: 0x3741f - wit_bindgen[bc7f8915fbd6868b]::rt::async_support::callback at /home/alex/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/wit-bindgen-0.61.1/src/rt/async_support.rs:642:27 18: 0x784c - test_programs[6528a46e635fc4bb]::p3::exports::wasi::cli::run::__callback_run at /home/alex/code/wasmtime2/crates/test-programs/src/p3/mod.rs:4:1 19: 0x39eb - [callback][async-lift]wasi:cli/run@0.3.0#run at /home/alex/code/wasmtime2/crates/test-programs/src/bin/p3_http_drop_trans [message truncated]
alexcrichton added the wasi-http label to Issue #14227.
Last updated: Aug 30 2026 at 09:07 UTC