From 46f28d09ad99c478c228b990eb1d5157f144740c Mon Sep 17 00:00:00 2001 From: Douglas Teixeira Date: Sat, 14 Nov 2026 20:58:19 +0000 Subject: [PATCH 1/4] fix(proxy): end proxied requests after sandbox shutdown Cancel outstanding proxied HTTP requests once sandbox shutdown finishes or fails. Return 502 while waiting for response headers and fail streaming bodies on their next poll. Explicit pause and WebSocket behavior are unchanged. Cover both waiting response headers and a streaming response body with regression tests. A client that stops reading can still prevent the body from being polled; bounding HTTP draining is a separate change. --- Cargo.lock | 1 + Cargo.toml | 1 + docs/src/internals/proxy-design.md | 15 +++ src/api/impls/mod.rs | 21 ++++ src/api/proxy.rs | 164 +++++++++++++++++++++++++++-- src/bin/server.rs | 4 + 6 files changed, 195 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6c123ac17..ff16cf478 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -173,6 +173,7 @@ dependencies = [ "tls-parser", "tokio", "tokio-tungstenite", + "tokio-util", "toml", "tonic", "tonic-prost", diff --git a/Cargo.toml b/Cargo.toml index 703429f28..d47f70384 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -43,6 +43,7 @@ firecracker_client = { version = "1.15.1", path = "thirdparty/firecracker-client envd = { version = "0.1.0", path = "thirdparty/envd" } custom_extension_client = { version = "0.1.0", path = "src/custom_extension_api/generated", default-features = false } tokio = { version = "1", features = ["full"] } +tokio-util = "0.7" reqsign = { version = "0.16.5", default-features = false, features = ["services-aws"] } reqwest = { version = "0.13", features = ["json", "stream"] } opendal = { version = "0.59.5", features = ["services-oss", "services-s3"] } diff --git a/docs/src/internals/proxy-design.md b/docs/src/internals/proxy-design.md index 822f91897..698e36aeb 100644 --- a/docs/src/internals/proxy-design.md +++ b/docs/src/internals/proxy-design.md @@ -176,6 +176,20 @@ Forwarded headers are injected: HTTP bodies are proxied as streams (request and response), including SSE and large uploads/downloads. +### Runtime Shutdown + +When the runtime shuts down, it pauses its sandboxes. A proxied HTTP request +that is still open then waits for an answer from a sandbox that sends none. +Once that sandbox shutdown has finished or failed, the runtime ends those +requests. A request still waiting for response headers gets `502 Bad Gateway`. +A response body that is already streaming ends with an error on its next poll, +so the client sees a broken connection. + +The server still waits for other HTTP connections to drain. A download whose +client has stopped reading can remain open because Hyper stops polling its +body when the socket fills. Proxy cancellation does not end WebSockets or +their pending handshakes; a pending handshake keeps its existing 30 s limit. + ## WebSocket Semantics WebSocket upgrade is supported through the same `/proxy` endpoints. @@ -205,6 +219,7 @@ Handshake failure behavior: - Upstream transport/connect failure - Sandbox is `Running` but runtime route is missing (`RouteMissing`) - Paused sandbox auto-resume failed + - Runtime shutdown ended the request before the upstream answered - `504 Gateway Timeout` - Paused sandbox auto-resume timed out - Upstream response header timeout diff --git a/src/api/impls/mod.rs b/src/api/impls/mod.rs index 089ed70e8..ec269629a 100644 --- a/src/api/impls/mod.rs +++ b/src/api/impls/mod.rs @@ -9,10 +9,12 @@ mod template; mod template_helpers; mod volumes; +use std::future::Future; use std::sync::Arc; use anyhow::Error as AnyhowError; use async_trait::async_trait; +use tokio_util::sync::CancellationToken; use super::proxy::{build_proxy_client, ProxyClient}; use crate::api_key::ApiKey; @@ -59,6 +61,7 @@ pub struct ApiImpl { volume_manager: Arc, observability: Option>, proxy_client: ProxyClient, + proxied_requests_end: CancellationToken, sandbox_proxy_domains: Vec, api_key: ApiKey, build_sessions: Arc, @@ -85,6 +88,7 @@ impl ApiImpl { volume_manager, observability, proxy_client: build_proxy_client(), + proxied_requests_end: CancellationToken::new(), sandbox_proxy_domains, api_key, build_sessions: Arc::new(image_build::BuildSessions::default()), @@ -100,6 +104,23 @@ impl ApiImpl { &self.proxy_client } + /// Ends every proxied HTTP request that is still open, as if its upstream + /// connection had broken. + /// + /// A proxied request is one that a client addressed to a port inside a + /// sandbox and that the reverse proxy in `api::proxy` forwarded there. The + /// sandbox answers it, not the runtime. A sandbox that shutdown has paused + /// answers nothing, so such a request would stay open and a graceful + /// shutdown would wait for it. + pub fn end_proxied_requests(&self) { + self.proxied_requests_end.cancel(); + } + + /// Resolves once [`Self::end_proxied_requests`] has run. + pub(crate) fn proxied_requests_ended(&self) -> impl Future + Send + 'static { + self.proxied_requests_end.clone().cancelled_owned() + } + pub(crate) fn sandbox_proxy_domains(&self) -> &[String] { &self.sandbox_proxy_domains } diff --git a/src/api/proxy.rs b/src/api/proxy.rs index efc1a7bda..9a0a07adf 100644 --- a/src/api/proxy.rs +++ b/src/api/proxy.rs @@ -1,4 +1,10 @@ -use std::{error::Error as StdError, future::Future, time::Duration}; +use std::{ + error::Error as StdError, + future::Future, + pin::Pin, + task::{Context, Poll}, + time::Duration, +}; use axum::{ body::Body, @@ -17,7 +23,7 @@ use axum::{ }; use futures::{SinkExt, StreamExt}; use http_body_util::BodyExt; -use hyper::body::Incoming; +use hyper::body::{Body as HttpBody, Bytes, Frame, Incoming, SizeHint}; use hyper_util::{ client::legacy::{connect::HttpConnector, Client}, rt::TokioExecutor, @@ -468,12 +474,26 @@ async fn proxy_http_request( let (body, activity_rx) = track_request_body_activity(body); let upstream_request = Request::from_parts(parts, body); - let upstream_response_result = match wait_for_upstream_response_headers_with_activity_timeout( - api_impl.proxy_client().request(upstream_request), - activity_rx, - ) - .await - { + let waited = tokio::select! { + waited = wait_for_upstream_response_headers_with_activity_timeout( + api_impl.proxy_client().request(upstream_request), + activity_rx, + ) => waited, + () = api_impl.proxied_requests_ended() => { + // Shutdown has paused the sandbox, so its answer will not come. + // The request may have reached the sandbox, so answer as for a + // broken upstream, not with the 404 or 410 of a request that + // never left the proxy. + warn!( + sandbox_id = %sandbox_id, + method = %upstream_method, + upstream = %upstream_uri_for_log, + "shutdown ended the upstream proxy request" + ); + return StatusCode::BAD_GATEWAY.into_response(); + } + }; + let upstream_response_result = match waited { Ok(result) => result, Err(_) => { warn!( @@ -517,7 +537,7 @@ async fn proxy_http_request( } }; - map_upstream_response(upstream_response) + map_upstream_response(upstream_response, api_impl.proxied_requests_ended()) } fn track_request_body_activity(body: Body) -> (Body, watch::Receiver<()>) { @@ -1090,12 +1110,54 @@ fn remove_hop_by_hop_headers(headers: &mut HeaderMap) { headers.remove(HeaderName::from_static("keep-alive")); } -fn map_upstream_response(response: Response) -> Response { +fn map_upstream_response( + response: Response, + requests_ended: impl Future + Send + 'static, +) -> Response { let (mut parts, body) = response.into_parts(); // Mirror the request-side filtering on the way back so connection-scoped // headers from the upstream do not leak through this proxy hop. remove_hop_by_hop_headers(&mut parts.headers); - Response::from_parts(parts, Body::new(body.map_err(axum::Error::new))) + let body = UpstreamBody { + body, + requests_ended: Box::pin(requests_ended), + }; + Response::from_parts(parts, Body::new(body)) +} + +/// The body of a sandbox's response to a proxied request, which fails once +/// shutdown ends the proxied requests. Nothing else limits how long it waits +/// for the sandbox's next frame, and a paused sandbox never sends one. +struct UpstreamBody { + body: Incoming, + requests_ended: Pin + Send>>, +} + +impl HttpBody for UpstreamBody { + type Data = Bytes; + type Error = axum::Error; + + fn poll_frame( + mut self: Pin<&mut Self>, + cx: &mut Context<'_>, + ) -> Poll, axum::Error>>> { + if self.requests_ended.as_mut().poll(cx).is_ready() { + return Poll::Ready(Some(Err(axum::Error::new( + "shutdown ended the upstream response", + )))); + } + Pin::new(&mut self.body) + .poll_frame(cx) + .map_err(axum::Error::new) + } + + fn is_end_stream(&self) -> bool { + self.body.is_end_stream() + } + + fn size_hint(&self) -> SizeHint { + self.body.size_hint() + } } async fn bridge_websocket_streams( @@ -3107,6 +3169,86 @@ mod tests { assert_eq!(response.status(), StatusCode::GATEWAY_TIMEOUT); } + async fn request_running_sandbox( + upstream_addr: SocketAddr, + ) -> (Arc, tokio::task::JoinHandle>) { + let sandbox_id = SandboxId::new(); + let api = build_api().await; + api.orchestrator() + .set_proxy_target_for_test( + sandbox_id, + ProxyTarget::new(Ipv4Addr::LOCALHOST), + crate::orchestrator::SandboxState::Running, + ) + .await; + let app = server::new(api.clone()); + let request = Request::builder() + .uri("/proxy/download") + .header(SANDBOX_ID_HEADER, sandbox_id.to_string()) + .header(TARGET_PORT_HEADER, upstream_addr.port().to_string()) + .body(Body::empty()) + .unwrap(); + let response = tokio::spawn(async move { app.oneshot(request).await.unwrap() }); + (api, response) + } + + #[tokio::test] + async fn proxy_answers_bad_gateway_when_proxied_requests_end_before_upstream_headers() { + let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await.unwrap(); + let upstream_addr = listener.local_addr().unwrap(); + let (received_tx, received_rx) = tokio::sync::oneshot::channel(); + tokio::spawn(async move { + let (mut upstream, _) = listener.accept().await.unwrap(); + read_http_request_head(&mut upstream).await; + received_tx.send(()).unwrap(); + // Like a paused sandbox, keep the connection open and never answer. + std::future::pending::<()>().await; + }); + let (api, pending_response) = request_running_sandbox(upstream_addr).await; + received_rx.await.unwrap(); + + api.end_proxied_requests(); + + let response = pending_response.await.unwrap(); + assert_eq!(response.status(), StatusCode::BAD_GATEWAY); + } + + #[tokio::test] + async fn proxy_breaks_streaming_response_body_when_proxied_requests_end() { + async fn endless_download() -> Response { + let first = stream::once(async { Ok::<_, Infallible>("first") }); + // Like a paused sandbox, send nothing more and never end the body. + Response::new(Body::from_stream(first.chain(stream::pending()))) + } + let upstream_addr = + spawn_upstream(axum::Router::new().route("/download", get(endless_download))).await; + let (api, pending_response) = request_running_sandbox(upstream_addr).await; + let response = pending_response.await.unwrap(); + assert_eq!(response.status(), StatusCode::OK); + let mut body = response.into_body().into_data_stream(); + assert_eq!(body.next().await.unwrap().unwrap(), "first"); + let mut next_frame = tokio::spawn(async move { body.next().await }); + // The reader must already be waiting for the next frame, so only a + // wake-up from ending the proxied requests can finish it. + assert!( + timeout(Duration::from_millis(100), &mut next_frame) + .await + .is_err(), + "the response body should wait for the upstream's next frame" + ); + + api.end_proxied_requests(); + + let next = timeout(Duration::from_secs(1), next_frame) + .await + .expect("the response body should end once proxied requests end") + .unwrap(); + assert!( + matches!(next, Some(Err(_))), + "the response body should fail, not end cleanly: {next:?}" + ); + } + #[tokio::test] async fn proxy_keeps_envd_stream_input_alive_with_body_activity() { let upstream_addr = start_client_stream_response_server().await; diff --git a/src/bin/server.rs b/src/bin/server.rs index 0328a4ae2..dfd24904b 100644 --- a/src/bin/server.rs +++ b/src/bin/server.rs @@ -209,6 +209,10 @@ async fn main() -> anyhow::Result<()> { if let Err(err) = shutdown_orchestrator.shutdown().await { warn!(target: "agentenv", error = %err, "error occurred while shutting down orchestrator"); } + // Sandbox shutdown has finished or failed, and the process exits + // either way. A request that the proxy forwarded into a sandbox + // and that is still open waits for an answer that will not come. + api_impl.end_proxied_requests(); if let Some(pool) = FirecrackerPool::global() { info!(target: "agentenv", "shutting down firecracker pool"); if let Err(err) = pool.shutdown().await { From 63ff8ed34f27f4632b53e422061ad2df2c253ac9 Mon Sep 17 00:00:00 2001 From: Douglas Teixeira Date: Wed, 18 Nov 2026 12:36:43 +0000 Subject: [PATCH 2/4] fix(proxy): forward ready body frames before cancellation --- docs/src/internals/proxy-design.md | 5 ++- src/api/impls/mod.rs | 4 +- src/api/proxy.rs | 63 +++++++++++++++++++++++++++--- 3 files changed, 62 insertions(+), 10 deletions(-) diff --git a/docs/src/internals/proxy-design.md b/docs/src/internals/proxy-design.md index 698e36aeb..cce947dba 100644 --- a/docs/src/internals/proxy-design.md +++ b/docs/src/internals/proxy-design.md @@ -182,8 +182,9 @@ When the runtime shuts down, it pauses its sandboxes. A proxied HTTP request that is still open then waits for an answer from a sandbox that sends none. Once that sandbox shutdown has finished or failed, the runtime ends those requests. A request still waiting for response headers gets `502 Bad Gateway`. -A response body that is already streaming ends with an error on its next poll, -so the client sees a broken connection. +A response body first forwards frames that are already available, so a buffered +command acknowledgment can finish. If the body then needs another frame, it +ends with an error and the client sees a broken connection. The server still waits for other HTTP connections to drain. A download whose client has stopped reading can remain open because Hyper stops polling its diff --git a/src/api/impls/mod.rs b/src/api/impls/mod.rs index ec269629a..ae422d84d 100644 --- a/src/api/impls/mod.rs +++ b/src/api/impls/mod.rs @@ -104,8 +104,8 @@ impl ApiImpl { &self.proxy_client } - /// Ends every proxied HTTP request that is still open, as if its upstream - /// connection had broken. + /// Ends proxied HTTP requests once they need more upstream data. + /// Response bodies forward frames that are already available before failing. /// /// A proxied request is one that a client addressed to a port inside a /// sandbox and that the reverse proxy in `api::proxy` forwarded there. The diff --git a/src/api/proxy.rs b/src/api/proxy.rs index 9a0a07adf..3647c1e49 100644 --- a/src/api/proxy.rs +++ b/src/api/proxy.rs @@ -1125,9 +1125,9 @@ fn map_upstream_response( Response::from_parts(parts, Body::new(body)) } -/// The body of a sandbox's response to a proxied request, which fails once -/// shutdown ends the proxied requests. Nothing else limits how long it waits -/// for the sandbox's next frame, and a paused sandbox never sends one. +/// A sandbox response body that forwards ready frames during shutdown. +/// Once it needs another frame, cancellation fails the body because a paused +/// sandbox cannot send more data. struct UpstreamBody { body: Incoming, requests_ended: Pin + Send>>, @@ -1141,14 +1141,15 @@ impl HttpBody for UpstreamBody { mut self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll, axum::Error>>> { + if let Poll::Ready(frame) = Pin::new(&mut self.body).poll_frame(cx) { + return Poll::Ready(frame.map(|result| result.map_err(axum::Error::new))); + } if self.requests_ended.as_mut().poll(cx).is_ready() { return Poll::Ready(Some(Err(axum::Error::new( "shutdown ended the upstream response", )))); } - Pin::new(&mut self.body) - .poll_frame(cx) - .map_err(axum::Error::new) + Poll::Pending } fn is_end_stream(&self) -> bool { @@ -3249,6 +3250,56 @@ mod tests { ); } + #[tokio::test] + async fn proxy_preserves_buffered_command_acknowledgment_after_cancellation() { + let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await.unwrap(); + let address = listener.local_addr().unwrap(); + let upstream = tokio::spawn(async move { + let (mut stream, _) = listener.accept().await.unwrap(); + read_http_request_head(&mut stream).await; + let acknowledgment = r#"{"commandID":"command-123"}"#; + let response = format!( + "HTTP/1.1 200 OK\r\nContent-Length: {}\r\nConnection: close\r\n\r\n{}", + acknowledgment.len(), + acknowledgment + ); + stream.write_all(response.as_bytes()).await.unwrap(); + }); + let stream = tokio::net::TcpStream::connect(address).await.unwrap(); + let (mut sender, connection) = + hyper::client::conn::http1::handshake(hyper_util::rt::TokioIo::new(stream)) + .await + .unwrap(); + let connection = tokio::spawn(connection); + let response = sender + .send_request( + Request::builder() + .method(Method::POST) + .uri("/commands") + .body(Body::empty()) + .unwrap(), + ) + .await + .unwrap(); + upstream.await.unwrap(); + // The connection has read the complete response into Incoming before + // cancellation is observed by the response-body wrapper. + timeout(Duration::from_secs(1), connection) + .await + .unwrap() + .unwrap() + .unwrap(); + let response = map_upstream_response(response, std::future::ready(())); + let body = response + .into_body() + .collect() + .await + .expect("a buffered acknowledgment must finish despite cancellation") + .to_bytes(); + let acknowledgment: Value = serde_json::from_slice(&body).unwrap(); + assert_eq!(acknowledgment["commandID"], "command-123"); + } + #[tokio::test] async fn proxy_keeps_envd_stream_input_alive_with_body_activity() { let upstream_addr = start_client_stream_response_server().await; From 90318ac751b803ce7a8d51219b170e96f17fc256 Mon Sep 17 00:00:00 2001 From: Douglas Teixeira Date: Wed, 18 Nov 2026 14:57:53 +0000 Subject: [PATCH 3/4] docs: clarify proxy shutdown comments --- src/api/impls/mod.rs | 11 ++++------- src/api/proxy.rs | 21 ++++++++++----------- src/bin/server.rs | 5 ++--- 3 files changed, 16 insertions(+), 21 deletions(-) diff --git a/src/api/impls/mod.rs b/src/api/impls/mod.rs index ae422d84d..a74126af6 100644 --- a/src/api/impls/mod.rs +++ b/src/api/impls/mod.rs @@ -104,14 +104,11 @@ impl ApiImpl { &self.proxy_client } - /// Ends proxied HTTP requests once they need more upstream data. - /// Response bodies forward frames that are already available before failing. + /// Signals the runtime HTTP proxy to end requests that need more sandbox data. + /// Response bodies still forward any data already received. /// - /// A proxied request is one that a client addressed to a port inside a - /// sandbox and that the reverse proxy in `api::proxy` forwarded there. The - /// sandbox answers it, not the runtime. A sandbox that shutdown has paused - /// answers nothing, so such a request would stay open and a graceful - /// shutdown would wait for it. + /// Call this after sandbox shutdown. Paused or stopped sandboxes cannot + /// answer these requests, so waiting for them would hold up shutdown. pub fn end_proxied_requests(&self) { self.proxied_requests_end.cancel(); } diff --git a/src/api/proxy.rs b/src/api/proxy.rs index 3647c1e49..32c47f0ab 100644 --- a/src/api/proxy.rs +++ b/src/api/proxy.rs @@ -480,10 +480,9 @@ async fn proxy_http_request( activity_rx, ) => waited, () = api_impl.proxied_requests_ended() => { - // Shutdown has paused the sandbox, so its answer will not come. - // The request may have reached the sandbox, so answer as for a - // broken upstream, not with the 404 or 410 of a request that - // never left the proxy. + // Shutdown can leave the sandbox unable to answer. Return 502 because + // the request may already have reached it. The proxy uses 404 or 410 + // only when it refuses a request before forwarding it. warn!( sandbox_id = %sandbox_id, method = %upstream_method, @@ -1125,9 +1124,9 @@ fn map_upstream_response( Response::from_parts(parts, Body::new(body)) } -/// A sandbox response body that forwards ready frames during shutdown. -/// Once it needs another frame, cancellation fails the body because a paused -/// sandbox cannot send more data. +/// Forwards response data already received, including during shutdown. +/// After cancellation, returns an error if more data would require waiting. +/// A paused sandbox cannot provide that data. struct UpstreamBody { body: Incoming, requests_ended: Pin + Send>>, @@ -3229,8 +3228,8 @@ mod tests { let mut body = response.into_body().into_data_stream(); assert_eq!(body.next().await.unwrap().unwrap(), "first"); let mut next_frame = tokio::spawn(async move { body.next().await }); - // The reader must already be waiting for the next frame, so only a - // wake-up from ending the proxied requests can finish it. + // Wait until the reader is blocked on more data. Canceling the request + // must wake it up; the sandbox will not send another frame. assert!( timeout(Duration::from_millis(100), &mut next_frame) .await @@ -3282,8 +3281,8 @@ mod tests { .await .unwrap(); upstream.await.unwrap(); - // The connection has read the complete response into Incoming before - // cancellation is observed by the response-body wrapper. + // Wait until Hyper has read the complete command response before + // testing cancellation. The proxy must still deliver its command ID. timeout(Duration::from_secs(1), connection) .await .unwrap() diff --git a/src/bin/server.rs b/src/bin/server.rs index dfd24904b..48226868e 100644 --- a/src/bin/server.rs +++ b/src/bin/server.rs @@ -209,9 +209,8 @@ async fn main() -> anyhow::Result<()> { if let Err(err) = shutdown_orchestrator.shutdown().await { warn!(target: "agentenv", error = %err, "error occurred while shutting down orchestrator"); } - // Sandbox shutdown has finished or failed, and the process exits - // either way. A request that the proxy forwarded into a sandbox - // and that is still open waits for an answer that will not come. + // Sandbox shutdown has returned, and the process will exit even if it failed. + // End requests still waiting for a sandbox response. api_impl.end_proxied_requests(); if let Some(pool) = FirecrackerPool::global() { info!(target: "agentenv", "shutting down firecracker pool"); From 45f33ba1d01ec82f22ca4607b825cd600b2cf289 Mon Sep 17 00:00:00 2001 From: Douglas Teixeira Date: Wed, 18 Nov 2026 17:27:35 +0000 Subject: [PATCH 4/4] docs: clarify which response data survives shutdown --- docs/src/internals/proxy-design.md | 7 ++++--- src/api/impls/mod.rs | 2 +- src/api/proxy.rs | 6 +++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/docs/src/internals/proxy-design.md b/docs/src/internals/proxy-design.md index cce947dba..1c0ba9533 100644 --- a/docs/src/internals/proxy-design.md +++ b/docs/src/internals/proxy-design.md @@ -182,9 +182,10 @@ When the runtime shuts down, it pauses its sandboxes. A proxied HTTP request that is still open then waits for an answer from a sandbox that sends none. Once that sandbox shutdown has finished or failed, the runtime ends those requests. A request still waiting for response headers gets `502 Bad Gateway`. -A response body first forwards frames that are already available, so a buffered -command acknowledgment can finish. If the body then needs another frame, it -ends with an error and the client sees a broken connection. +A response body first forwards any data Hyper, the HTTP library, can return +immediately. A complete response already available this way can finish normally. +If Hyper would need to wait, the body ends with an error. Bytes still waiting +in the socket or being processed by Hyper may be lost. The server still waits for other HTTP connections to drain. A download whose client has stopped reading can remain open because Hyper stops polling its diff --git a/src/api/impls/mod.rs b/src/api/impls/mod.rs index a74126af6..dbc265ec6 100644 --- a/src/api/impls/mod.rs +++ b/src/api/impls/mod.rs @@ -105,7 +105,7 @@ impl ApiImpl { } /// Signals the runtime HTTP proxy to end requests that need more sandbox data. - /// Response bodies still forward any data already received. + /// Response bodies still forward data Hyper can return immediately. /// /// Call this after sandbox shutdown. Paused or stopped sandboxes cannot /// answer these requests, so waiting for them would hold up shutdown. diff --git a/src/api/proxy.rs b/src/api/proxy.rs index 32c47f0ab..9355c7178 100644 --- a/src/api/proxy.rs +++ b/src/api/proxy.rs @@ -1124,9 +1124,9 @@ fn map_upstream_response( Response::from_parts(parts, Body::new(body)) } -/// Forwards response data already received, including during shutdown. -/// After cancellation, returns an error if more data would require waiting. -/// A paused sandbox cannot provide that data. +/// Forwards response data Hyper can return immediately, including during shutdown. +/// After cancellation, returns an error if Hyper would need to wait for more data. +/// Bytes still in the socket or being processed by Hyper may be lost. struct UpstreamBody { body: Incoming, requests_ended: Pin + Send>>,