diff --git a/src/fetch/mod.rs b/src/fetch/mod.rs index a8667ca..108e56f 100644 --- a/src/fetch/mod.rs +++ b/src/fetch/mod.rs @@ -540,16 +540,15 @@ pub mod cf_worker { let abs = abc.signal(); let req = Fetch::Request(req); - let mut resp_fut = std::pin::pin!(req + worker::wasm_bindgen_futures::spawn_local(async move { + worker::Delay::from(Duration::from_secs(5)).await; + abc.abort(); + }); + + let resp = std::pin::pin!(req .send_with_signal(&abs) - .map_err(ErrorResponse::worker_fetch_error)); - - let timeout = std::pin::pin!(worker::Delay::from(Duration::from_secs(5))); - - let resp = futures::select! { - resp = resp_fut => resp?, - _ = timeout.fuse() => return Err(ErrorResponse::upstream_timeout()), - }; + .map_err(ErrorResponse::worker_fetch_error)) + .await?; if resp.status_code() == 301 || resp.status_code() == 302 { if let Ok(Some(location)) = resp.headers().get("location") { diff --git a/wrangler.toml b/wrangler.toml index 9e9b855..c2e2cd1 100644 --- a/wrangler.toml +++ b/wrangler.toml @@ -3,4 +3,8 @@ main = "build/worker/shim.mjs" compatibility_date = "2024-11-11" [build] -command = "cargo install -q worker-build && worker-build --release --features cf-worker" \ No newline at end of file +command = "cargo install -q worker-build && worker-build --release --features cf-worker" + +[observability] +enabled = true +head_sampling_rate = 1