fix(websocket): byte-based caps for pending buffer + inbound WS sizes (WS-05, WS-06)

This commit is contained in:
2026-08-29 12:00:04 +00:00
parent 5024d99862
commit 92cc11a74f
5 changed files with 264 additions and 23 deletions
+7 -4
View File
@@ -21,7 +21,7 @@ use axum::extract::ws::WebSocketUpgrade;
use axum::http::StatusCode;
use axum::response::{IntoResponse, Response};
use super::byte_adapter::split_ws_to_bytes;
use super::byte_adapter::{split_ws_to_bytes, INBOUND_WS_FRAME_CAP, INBOUND_WS_MESSAGE_CAP};
/// The channels session for an upgraded socket: adapt → `Connection`
/// (identity attached) → `ChannelsAdapter::handle`. `policy` gates
@@ -140,9 +140,12 @@ pub async fn ws_upgrade_handler(
let policy = policy
.map(|axum::Extension(p)| p.0)
.unwrap_or_else(|| Arc::new(NoCap));
ws_upgrade.on_upgrade(move |socket| async move {
run_channels_session(socket, registry, identity, policy).await
})
ws_upgrade
.max_frame_size(INBOUND_WS_FRAME_CAP)
.max_message_size(INBOUND_WS_MESSAGE_CAP)
.on_upgrade(move |socket| async move {
run_channels_session(socket, registry, identity, policy).await
})
}
/// Bearer-auth middleware for the WS upgrade route: resolves the token