Compare commits

..

2 Commits

Author SHA1 Message Date
9c78701038 v25.11.21
Some checks failed
Default (tags) / security (push) Failing after 1s
Default (tags) / test (push) Failing after 1s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped
2026-03-17 11:33:34 +00:00
26fd9409a7 fix(rustproxy-http): reuse pooled HTTP/2 connections for requests with and without bodies 2026-03-17 11:33:34 +00:00
4 changed files with 14 additions and 22 deletions

View File

@@ -1,5 +1,11 @@
# Changelog # Changelog
## 2026-03-17 - 25.11.21 - fix(rustproxy-http)
reuse pooled HTTP/2 connections for requests with and without bodies
- remove the bodyless-request restriction from HTTP/2 pool checkout
- always return successful HTTP/2 senders to the connection pool after requests
## 2026-03-17 - 25.11.20 - fix(rustproxy-http) ## 2026-03-17 - 25.11.20 - fix(rustproxy-http)
avoid downgrading cached backend protocol on H2 stream errors avoid downgrading cached backend protocol on H2 stream errors

View File

@@ -1,6 +1,6 @@
{ {
"name": "@push.rocks/smartproxy", "name": "@push.rocks/smartproxy",
"version": "25.11.20", "version": "25.11.21",
"private": false, "private": false,
"description": "A powerful proxy package with unified route-based configuration for high traffic management. Features include SSL/TLS support, flexible routing patterns, WebSocket handling, advanced security options, and automatic ACME certificate management.", "description": "A powerful proxy package with unified route-based configuration for high traffic management. Features include SSL/TLS support, flexible routing patterns, WebSocket handling, advanced security options, and automatic ACME certificate management.",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",

View File

@@ -677,20 +677,10 @@ impl HttpProxyService {
h2: use_h2, h2: use_h2,
}; };
// H2 pool checkout — only for bodyless requests (GET/HEAD/DELETE). // H2 pool checkout — reuse pooled connections for all requests.
// // The h2 crate properly replenishes connection-level flow control
// WORKAROUND: Requests with bodies (POST/PUT uploads) always get fresh H2 // windows via release_capacity() as data is consumed.
// connections. Reusing a pooled H2 connection after a large upload can stall if use_h2 {
// forever due to depleted connection-level flow control windows. The h2 crate
// has no stall/timeout detection (https://github.com/hyperium/hyper/issues/2899),
// and Go/nginx HTTP/2 servers have known issues with connection-level window
// replenishment after large transfers (https://github.com/golang/go/issues/16481,
// https://github.com/golang/go/issues/56558). A fresh connection guarantees
// clean flow control state. The overhead is ~3-5ms for TLS+H2 handshake.
//
// TODO: Revisit once h2 crate adds flow control stall detection, or once
// Go/nginx H2 connection-level window handling is confirmed reliable.
if use_h2 && body.is_end_stream() {
if let Some((mut sender, age)) = self.connection_pool.checkout_h2(&pool_key) { if let Some((mut sender, age)) = self.connection_pool.checkout_h2(&pool_key) {
match tokio::time::timeout( match tokio::time::timeout(
std::time::Duration::from_millis(500), std::time::Duration::from_millis(500),
@@ -1379,12 +1369,8 @@ impl HttpProxyService {
match sender.send_request(upstream_req).await { match sender.send_request(upstream_req).await {
Ok(upstream_response) => { Ok(upstream_response) => {
// Only pool after bodyless requests — uploads deplete connection-level let g = self.connection_pool.register_h2(pool_key.clone(), sender);
// flow control windows (see comment at pool checkout above). gen_holder.store(g, std::sync::atomic::Ordering::Relaxed);
if retry_state.is_some() {
let g = self.connection_pool.register_h2(pool_key.clone(), sender);
gen_holder.store(g, std::sync::atomic::Ordering::Relaxed);
}
self.build_streaming_response(upstream_response, route, route_id, source_ip, conn_activity).await self.build_streaming_response(upstream_response, route, route_id, source_ip, conn_activity).await
} }
Err(e) => { Err(e) => {

View File

@@ -3,6 +3,6 @@
*/ */
export const commitinfo = { export const commitinfo = {
name: '@push.rocks/smartproxy', name: '@push.rocks/smartproxy',
version: '25.11.20', version: '25.11.21',
description: 'A powerful proxy package with unified route-based configuration for high traffic management. Features include SSL/TLS support, flexible routing patterns, WebSocket handling, advanced security options, and automatic ACME certificate management.' description: 'A powerful proxy package with unified route-based configuration for high traffic management. Features include SSL/TLS support, flexible routing patterns, WebSocket handling, advanced security options, and automatic ACME certificate management.'
} }