wasi-http p3: `transmit` future from `request.new` hangs until the response body is consumed
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 58/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- rust
- Lĩnh vực
- backend-api-design, networking
Hướng nghiên cứu
Start with the WASI HTTP P3 outbound request tests in crates/wasi-http/tests/all/p3/mod.rs and the Server::http1_stalled_body helper described in the issue. The proposed reproducer is crates/test-programs/src/bin/p3_http_outbound_request_transmit_stalled_body.rs; compare its transmit behavior with the existing between-bytes timeout test. Done means transmit resolves after the request body and trailers are sent, even while the response body remains unread.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
In wasi:http p3, request.new gives the guest the request plus a transmit future, which I understood to say whether the request went out ok. However, wasmtime's transmit only resolves once the whole connection is done, so it waits for the response body to be fully read. So if the guest awaits transmit before reading the body and the server stalls, it hangs and the between-bytes timeout never gets triggered.
From what @alexcrichton said in #14112, transmit seems to be meant to be about sending the request body, so I suspect this is a bug and not a design choice.
Test Case
let options = RequestOptions::new();
options.set_between_bytes_timeout(Some(100_000_000)).unwrap(); // 100ms
let (_, trailers) = wit_future::new(|| Ok(None));
let (request, transmit) = Request::new(Headers::new(), None, trailers, Some(options));
request.set_method(&Method::Get).unwrap();
request.set_scheme(Some(&Scheme::Http)).unwrap();
request.set_authority(Some(&addr)).unwrap();
request.set_path_with_query(Some("/")).unwrap();
let _response = client::send(request).await.unwrap();
transmit.await.unwrap(); // never resolves
The server is the existing Server::http1_stalled_body helper: headers and a first chunk of body, then it stalls without closing.
Test patch
diff --git a/crates/test-programs/src/bin/p3_http_outbound_request_transmit_stalled_body.rs b/crates/test-programs/src/bin/p3_http_outbound_request_transmit_stalled_body.rs
new file mode 100644
index 0000000000..312de87e2f
--- /dev/null
+++ b/crates/test-programs/src/bin/p3_http_outbound_request_transmit_stalled_body.rs
@@ -0,0 +1,37 @@
+use std::time::Duration;
+
+use test_programs::p3::wasi::http::client;
+use test_programs::p3::wasi::http::types::{Headers, Method, Request, RequestOptions, Scheme};
+use test_programs::p3::wit_future;
+
+struct Component;
+
+test_programs::p3::export!(Component);
+
+impl test_programs::p3::exports::wasi::cli::run::Guest for Component {
+ async fn run() -> Result<(), ()> {
+ 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 options = RequestOptions::new();
+ let between_bytes = Duration::from_millis(100).as_nanos() as u64;
+ options
+ .set_between_bytes_timeout(Some(between_bytes))
+ .unwrap();
+
+ let (_, trailers) = wit_future::new(|| Ok(None));
+ let (request, transmit) = Request::new(Headers::new(), None, trailers, Some(options));
+ request.set_method(&Method::Get).unwrap();
+ request.set_scheme(Some(&Scheme::Http)).unwrap();
+ request.set_authority(Some(&addr)).unwrap();
+ request.set_path_with_query(Some("/")).unwrap();
+
+ let _response = client::send(request).await.unwrap();
+ transmit.await.unwrap();
+ Ok(())
+ }
+}
+
+fn main() {}
diff --git a/crates/wasi-http/tests/all/p3/mod.rs b/crates/wasi-http/tests/all/p3/mod.rs
index de2d67e173..66d144add1 100644
--- a/crates/wasi-http/tests/all/p3/mod.rs
+++ b/crates/wasi-http/tests/all/p3/mod.rs
@@ -374,6 +374,19 @@ async fn p3_http_outbound_request_between_bytes_timeout() -> wasmtime::Result<()
.await
}
+#[test_log::test(tokio::test(flavor = "multi_thread"))]
+async fn p3_http_outbound_request_transmit_stalled_body() -> wasmtime::Result<()> {
+ let server = Server::http1_stalled_body(1, std::time::Duration::from_secs(10))?;
+ tokio::time::timeout(
+ std::time::Duration::from_secs(3),
+ run_cli(
+ P3_HTTP_OUTBOUND_REQUEST_TRANSMIT_STALLED_BODY_COMPONENT,
+ &server,
+ ),
+ )
+ .await?
+}
+
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn p3_http_outbound_request_first_byte_timeout() -> wasmtime::Result<()> {
let server = Server::http1_delayed(1, std::time::Duration::from_secs(5))?;
Expected Results
transmit resolves once the request (body and trailers) has been sent, whether or not the response body is read.
Actual Results
transmit never resolves. With a 3s tokio::time::timeout around the test it fails with "deadline has elapsed". Dropping the response before awaiting transmit makes it pass.
Versions and Environment
Reproduced on Wasmtime main (0e3ddc621f), macOS aarch64. I also hit it on 49.0.2.
Extra Info
Related issues: #14112, #14227
- Ngôn ngữ chính
- Rust
- Star
- 18.9k
- Fork
- 2k
- Merge trung bình
- 1 ngày 6 giờ
- Pull request đã merge (30 ngày)
- 238
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của bytecodealliance/wasmtime
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
bytecodealliance/wasmtime#15536 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
bytecodealliance/wasmtime#15455 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
wasi-preview1-component-adapter: fd_write does not invalidate cached InputStream, causing stale readsCó thể đã có người làm @dpfens đã nhận 13 ngày trước. Đang mởwasi
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
bytecodealliance/wasmtime#15296 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug wasm-proposal:exceptions wasmtime:debugging
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
bytecodealliance/wasmtime#14102 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
wasm-proposal:gc
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
bytecodealliance/wasmtime#13808 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của bytecodealliance/wasmtime
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
area: plugins bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
clipy-recorder/clipy#1039 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
valkey-io/valkey-glide#7975 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
gofractally/psibase#2379 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Qwen stream parser: a chunk with "error": null is treated as a stream errorCó thể đã có người làm @Beehtrix đã nhận hôm nay. Đang mởarea:models bug good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
brekkylab/ailoy#681 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày