diff --git a/Cargo.lock b/Cargo.lock
index 84ab4d002f7..7d4927114a0 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -7646,6 +7646,7 @@ name = "gpui_web"
version = "0.1.0"
dependencies = [
"anyhow",
+ "async-channel 2.5.0",
"console_error_panic_hook",
"futures 0.3.34",
"gpui",
diff --git a/crates/gpui_web/Cargo.toml b/crates/gpui_web/Cargo.toml
index af712b00b05..4018a96329b 100644
--- a/crates/gpui_web/Cargo.toml
+++ b/crates/gpui_web/Cargo.toml
@@ -29,6 +29,7 @@ parking_lot = { workspace = true, features = ["nightly"] }
gpui_wgpu.workspace = true
http_client.workspace = true
anyhow.workspace = true
+async-channel.workspace = true
futures.workspace = true
log.workspace = true
uuid.workspace = true
diff --git a/crates/gpui_web/examples/hello_web/Cargo.toml b/crates/gpui_web/examples/hello_web/Cargo.toml
index 85450a97f52..4266cb4e61b 100644
--- a/crates/gpui_web/examples/hello_web/Cargo.toml
+++ b/crates/gpui_web/examples/hello_web/Cargo.toml
@@ -42,14 +42,21 @@ path = "queue_test.rs"
name = "dynamic_fonts"
path = "dynamic_fonts.rs"
+[[bin]]
+name = "http_client_test"
+path = "http_client_test.rs"
+
[dependencies]
anyhow = "1"
futures = "0.3"
gpui = { path = "../../../gpui" }
gpui_platform = { path = "../../../gpui_platform" }
gpui_util = { path = "../../../gpui_util" }
+gpui_web = { path = "../.." }
+http_client = { path = "../../../http_client" }
unicode-segmentation = "1"
wasm-bindgen = "0.2"
+wasm-bindgen-futures = "0.4"
wasm_thread = { git = "https://github.com/zed-industries/wasm_thread", rev = "0cf96c7708dfb97ccf3da50347e25edcf75d6937", features = ["es_modules"] }
web-sys = { version = "0.3", features = ["console", "Location", "Window"] }
web-time = "1"
diff --git a/crates/gpui_web/examples/hello_web/http_client_test.rs b/crates/gpui_web/examples/hello_web/http_client_test.rs
new file mode 100644
index 00000000000..70a8d7d1327
--- /dev/null
+++ b/crates/gpui_web/examples/hello_web/http_client_test.rs
@@ -0,0 +1,48 @@
+//! Exercises Fetch response-body contention between the browser and real workers.
+//!
+//! The browser harness supplies chunked Fetch streams while the production HTTP
+//! client pumps them on the main thread and background workers consume them.
+
+use futures::AsyncReadExt as _;
+use gpui::Platform as _;
+use gpui_web::WebPlatform;
+use http_client::HttpClient as _;
+use std::sync::Arc;
+use wasm_bindgen::prelude::*;
+
+fn main() {}
+
+#[wasm_bindgen]
+pub async fn test_worker_fetch(url: String) -> Result<(), JsValue> {
+ let platform = WebPlatform::new(true);
+ let client = Arc::new(platform.fetch_http_client());
+ let background = platform.background_executor();
+ let main_thread = std::thread::current().id();
+ let readers = (0..8).map(|_| {
+ let client = client.clone();
+ let url = url.clone();
+ background.spawn(async move {
+ anyhow::ensure!(
+ std::thread::current().id() != main_thread,
+ "response body must be read on a real worker"
+ );
+ let mut response = client.get(&url, Default::default(), true).await?;
+ let mut bytes = Vec::new();
+ response.body_mut().read_to_end(&mut bytes).await?;
+ anyhow::ensure!(bytes.len() == 32768 * 3, "response did not reach EOF");
+ for (index, chunk) in bytes.chunks_exact(3).enumerate() {
+ let expected = [
+ (index % 251) as u8,
+ (index % 239) as u8,
+ (index % 227) as u8,
+ ];
+ anyhow::ensure!(chunk == expected, "response chunks must remain ordered");
+ }
+ anyhow::Ok(())
+ })
+ });
+ futures::future::try_join_all(readers)
+ .await
+ .map(|_| ())
+ .map_err(|error| JsValue::from_str(&error.to_string()))
+}
diff --git a/crates/gpui_web/examples/hello_web/index.html b/crates/gpui_web/examples/hello_web/index.html
index 62680135dae..ef47840cef3 100644
--- a/crates/gpui_web/examples/hello_web/index.html
+++ b/crates/gpui_web/examples/hello_web/index.html
@@ -16,6 +16,7 @@
+