From 186f7484da3116aeda474f7f529d417ee542b450 Mon Sep 17 00:00:00 2001 From: Yoshiya Hinosawa Date: Thu, 5 Sep 2024 13:30:18 +0900 Subject: fix(ext/node): close upgraded socket when the underlying http connection is closed (#25387) This change fixes the handling of upgraded socket from `node:http` module. In `op_node_http_fetch_response_upgrade`, we create DuplexStream paired with `hyper::upgrade::Upgraded`. When the connection is closed from the server, the read result from `Upgraded` becomes 0. However because we don't close the paired DuplexStream at that point, the Socket object in JS side keeps alive even after the server closed. That caused the issue #20179 This change fixes it by closing the paired DuplexStream when the `Upgraded` stream returns 0 read result. closes #20179 --- ext/node/ops/http.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'ext/node') diff --git a/ext/node/ops/http.rs b/ext/node/ops/http.rs index 4b1f99ec0..773902ded 100644 --- a/ext/node/ops/http.rs +++ b/ext/node/ops/http.rs @@ -272,6 +272,7 @@ pub async fn op_node_http_fetch_response_upgrade( loop { let read = upgraded_rx.read(&mut buf).await?; if read == 0 { + read_tx.shutdown().await?; break; } read_tx.write_all(&buf[..read]).await?; -- cgit v1.2.3