fix(tunnel): 为 hub reader body 推送添加超时, 防止流间 head-of-line blocking

push_body_chunk 原先使用无超时的 channel send, 当消费端慢时会阻塞
整条 proxy 连接的 reader, 导致同连接上其他 stream 的帧无法路由。
添加 5 秒超时后, 单个 stream 的背压不再影响其他 stream。
This commit is contained in:
fawney19
2026-04-16 02:11:32 +08:00
parent 1fd1f8216d
commit 586d2cc42b

View File

@@ -282,10 +282,17 @@ impl LocalStream {
if self.terminal.load(Ordering::Acquire) {
return false;
}
self.body_tx
.send(LocalBodyEvent::Chunk(payload))
.await
.is_ok()
// Use a timeout to prevent a slow consumer from blocking the shared
// proxy-connection reader (head-of-line blocking across streams).
match tokio::time::timeout(
Duration::from_secs(5),
self.body_tx.send(LocalBodyEvent::Chunk(payload)),
)
.await
{
Ok(Ok(())) => true,
_ => false,
}
}
fn finish(&self) {