Compare commits

...

2 Commits

4 changed files with 28 additions and 7 deletions

View File

@@ -1,5 +1,12 @@
# Changelog # Changelog
## 2026-03-16 - 4.5.5 - fix(remoteingress-core)
wait for hub-to-client draining before cleanup and reliably send close frames
- switch CLOSE frame delivery on the data channel from try_send to send().await to avoid dropping it when the channel is full
- delay stream cleanup until the hub-to-client task finishes or times out so large downstream responses continue after upload EOF
- add a bounded 5-minute wait for download draining to prevent premature termination of asymmetric transfers such as git fetch
## 2026-03-15 - 4.5.4 - fix(remoteingress-core) ## 2026-03-15 - 4.5.4 - fix(remoteingress-core)
preserve stream close ordering and add flow-control stall timeouts preserve stream close ordering and add flow-control stall timeouts

View File

@@ -1,6 +1,6 @@
{ {
"name": "@serve.zone/remoteingress", "name": "@serve.zone/remoteingress",
"version": "4.5.4", "version": "4.5.5",
"private": false, "private": false,
"description": "Edge ingress tunnel for DcRouter - accepts incoming TCP connections at network edge and tunnels them to DcRouter SmartProxy preserving client IP via PROXY protocol v1.", "description": "Edge ingress tunnel for DcRouter - accepts incoming TCP connections at network edge and tunnels them to DcRouter SmartProxy preserving client IP via PROXY protocol v1.",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",

View File

@@ -665,7 +665,7 @@ async fn handle_client_connection(
// After writing to client TCP, send WINDOW_UPDATE to hub so it can send more // After writing to client TCP, send WINDOW_UPDATE to hub so it can send more
let hub_to_client_token = client_token.clone(); let hub_to_client_token = client_token.clone();
let wu_tx = tunnel_ctrl_tx.clone(); let wu_tx = tunnel_ctrl_tx.clone();
let hub_to_client = tokio::spawn(async move { let mut hub_to_client = tokio::spawn(async move {
let mut consumed_since_update: u32 = 0; let mut consumed_since_update: u32 = 0;
loop { loop {
tokio::select! { tokio::select! {
@@ -741,18 +741,32 @@ async fn handle_client_connection(
} }
} }
// Send CLOSE frame via DATA channel (must arrive AFTER last DATA for this stream) // Send CLOSE frame via DATA channel (must arrive AFTER last DATA for this stream).
// Use send().await to guarantee delivery (try_send silently drops if channel full).
if !client_token.is_cancelled() { if !client_token.is_cancelled() {
let close_frame = encode_frame(stream_id, FRAME_CLOSE, &[]); let close_frame = encode_frame(stream_id, FRAME_CLOSE, &[]);
let _ = tunnel_data_tx.try_send(close_frame); let _ = tunnel_data_tx.send(close_frame).await;
} }
// Cleanup // Wait for the download task (hub → client) to finish draining all buffered
// response data. Upload EOF just means the client is done sending; the download
// must continue until all response data has been written to the client.
// This is critical for asymmetric transfers like git fetch (small request, large response).
// The download task will exit when:
// - back_rx returns None (back_tx dropped below after await, or hub sent CLOSE_BACK)
// - client_write fails (client disconnected)
// - client_token is cancelled
let _ = tokio::time::timeout(
Duration::from_secs(300), // 5 min max wait for download to finish
&mut hub_to_client,
).await;
// Now safe to clean up — download has finished or timed out
{ {
let mut writers = client_writers.lock().await; let mut writers = client_writers.lock().await;
writers.remove(&stream_id); writers.remove(&stream_id);
} }
hub_to_client.abort(); hub_to_client.abort(); // No-op if already finished; safety net if timeout fired
let _ = edge_id; // used for logging context let _ = edge_id; // used for logging context
} }

View File

@@ -3,6 +3,6 @@
*/ */
export const commitinfo = { export const commitinfo = {
name: '@serve.zone/remoteingress', name: '@serve.zone/remoteingress',
version: '4.5.4', version: '4.5.5',
description: 'Edge ingress tunnel for DcRouter - accepts incoming TCP connections at network edge and tunnels them to DcRouter SmartProxy preserving client IP via PROXY protocol v1.' description: 'Edge ingress tunnel for DcRouter - accepts incoming TCP connections at network edge and tunnels them to DcRouter SmartProxy preserving client IP via PROXY protocol v1.'
} }