mirror of
https://github.com/storytold/figcraft.git
synced 2026-10-24 10:27:00 -06:00
fix(collab-net): report exact bytes when server message limit is not a whole unit
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -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)")
|
||||
)
|
||||
})
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user