diff --git a/crates/wasi-http/src/types_impl.rs b/crates/wasi-http/src/types_impl.rs index f05202f7b499..43f7d7053766 100644 --- a/crates/wasi-http/src/types_impl.rs +++ b/crates/wasi-http/src/types_impl.rs @@ -741,11 +741,17 @@ impl crate::bindings::http::types::HostRequestOptions for T { &mut self, opts: Resource, ) -> wasmtime::Result> { - Ok(self + let millis = self .table() .get(&opts)? .connect_timeout - .and_then(|d| d.as_millis().try_into().ok())) + .map(|d| d.as_millis()); + + if let Some(millis) = millis { + Ok(Some(millis.try_into()?)) + } else { + Ok(None) + } } fn set_connect_timeout_ms( @@ -762,11 +768,17 @@ impl crate::bindings::http::types::HostRequestOptions for T { &mut self, opts: Resource, ) -> wasmtime::Result> { - Ok(self + let millis = self .table() .get(&opts)? .first_byte_timeout - .and_then(|d| d.as_millis().try_into().ok())) + .map(|d| d.as_millis()); + + if let Some(millis) = millis { + Ok(Some(millis.try_into()?)) + } else { + Ok(None) + } } fn set_first_byte_timeout_ms( @@ -783,11 +795,17 @@ impl crate::bindings::http::types::HostRequestOptions for T { &mut self, opts: Resource, ) -> wasmtime::Result> { - Ok(self + let millis = self .table() .get(&opts)? .between_bytes_timeout - .and_then(|d| d.as_millis().try_into().ok())) + .map(|d| d.as_millis()); + + if let Some(millis) = millis { + Ok(Some(millis.try_into()?)) + } else { + Ok(None) + } } fn set_between_bytes_timeout_ms(