diff options
author | Yoshiya Hinosawa <stibium121@gmail.com> | 2024-09-05 13:30:18 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-05 13:30:18 +0900 |
commit | 186f7484da3116aeda474f7f529d417ee542b450 (patch) | |
tree | 953c80f14d9d1ee0daa3ef3f968b76ecbe0cd8dd /ext/node/ops/http.rs | |
parent | dd208a6df02e99dbd7e1cb7b197fde8ccfeb0f88 (diff) |
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
Diffstat (limited to 'ext/node/ops/http.rs')
-rw-r--r-- | ext/node/ops/http.rs | 1 |
1 files changed, 1 insertions, 0 deletions
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?; |