bytecodealliance / bytecodealliance/wasmtime

Add test to ensure that `connect_timeout` is correctly passed around

Open
#8,106 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Rust
Stars
18.6k
Forks
1.8k
Avg merge
1d 19h
Merged PRs (30d)
121

Description

The following diff should be applied to ensure that the `connect_timeout` variable is correctly passed into the `handle` function.

This code was removed in https://github.com/bytecodealliance/wasmtime/pull/8085#discussion_r1521942861 due to a failure on Windows MinGW x86_64.

```diff
diff --git a/crates/test-programs/src/bin/http_outbound_request_timeout.rs b/crates/test-programs/src/bin/http_outbound_request_timeout.rs
index 8bd7601..198288e 100644
--- a/crates/test-programs/src/bin/http_outbound_request_timeout.rs
+++ b/crates/test-programs/src/bin/http_outbound_request_timeout.rs
@@ -1,13 +1,12 @@
use anyhow::Context;
use std::net::SocketAddr;
-use std::time::Duration;
+use std::time::{Duration, Instant};
use test_programs::wasi::http::types::{ErrorCode, Method, Scheme};

fn main() {
// This address inside the TEST-NET-3 address block is expected to time out.
let addr = SocketAddr::from(([203, 0, 113, 12], 80)).to_string();
let timeout = Duration::from_millis(200);
+ let start = Instant::now();
let connect_timeout: Option = Some(timeout.as_nanos() as u64);
let res = test_programs::http::request(
Method::Get,
@@ -30,9 +29,4 @@ fn main() {
),
"expected connection timeout"
);
+
+ let actual = start.elapsed();
+ let tolerance = Duration::from_millis(100);
+ let upper_bound = timeout + tolerance;
+ assert!(actual < upper_bound);
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.