fix(collab-net): report exact bytes when server message limit is not a whole unit

This commit is contained in:
Kushagra Kumar
2026-10-20 01:23:09 +05:30
parent fbb4a22e01
commit 227e182f68
2 changed files with 4 additions and 4 deletions
+2 -2
View File
@@ -369,9 +369,9 @@ fn read_loop(mut ws: WebSocket<Duplex>, ctx: &ReaderCtx) {
Ok(_) => {}
Err(tungstenite::Error::Capacity(_)) => {
let max = ctx.cfg.limits.max_server_message;
let limit = if max >= 1 << 20 {
let limit = if max >= 1 << 20 && max.is_multiple_of(1 << 20) {
format!("{} MiB", max >> 20)
} else if max >= 1 << 10 {
} else if max >= 1 << 10 && max.is_multiple_of(1 << 10) {
format!("{} KiB", max >> 10)
} else {
format!("{max} bytes")
+2 -2
View File
@@ -693,7 +693,7 @@ fn oversized_server_message_reports_accurate_diagnostic() {
let guest_probe = Probe::new();
let mut guest_cfg = quick(GuestConfig::new(invite, "Ada".into()));
guest_cfg.limits = NetLimits { max_server_message: 512, ..fast_limits() };
guest_cfg.limits = NetLimits { max_server_message: 1536, ..fast_limits() };
let _g = Guest::start(guest_cfg, guest_probe.inbox.clone()).unwrap();
let mut gp = guest_probe;
gp.wait("accurate failure diagnostic", |e| {
@@ -701,7 +701,7 @@ fn oversized_server_message_reports_accurate_diagnostic() {
matches!(
ev,
Event::Status(Status::Failed { reason })
if !reason.contains("The host refused") && reason.contains("received message exceeded size limit (max 512 bytes)")
if !reason.contains("The host refused") && reason.contains("received message exceeded size limit (max 1536 bytes)")
)
})
});