From 1246a433f8101c03491c1f1e9e0d51d79a025956 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Mon, 14 Jun 2021 22:10:55 +0200 Subject: fix: poll connection after writing response chunk in Deno.serveHttp() (#10961) This commit changes "op_http_response_write" to first send response chunk and then poll the underlying HTTP connection. Previously after writing a chunk of response HTTP connection wasn't polled and thus data wasn't written to the socket until after next op interacting with the connection. --- runtime/ops/http.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'runtime/ops') diff --git a/runtime/ops/http.rs b/runtime/ops/http.rs index 11e83f6c7..3e8a4ada7 100644 --- a/runtime/ops/http.rs +++ b/runtime/ops/http.rs @@ -502,6 +502,9 @@ async fn op_http_response_write( let mut send_data_fut = body.send_data(Vec::from(&*buf).into()).boxed_local(); poll_fn(|cx| { + let r = send_data_fut.poll_unpin(cx).map_err(AnyError::from); + + // Poll connection so the data is flushed if let Poll::Ready(Err(e)) = conn_resource.poll(cx) { // close ConnResource // close RequestResource associated with connection @@ -509,7 +512,7 @@ async fn op_http_response_write( return Poll::Ready(Err(e)); } - send_data_fut.poll_unpin(cx).map_err(AnyError::from) + r }) .await?; -- cgit v1.2.3