mirror of
https://github.com/block/buzz.git
synced 2026-11-24 02:02:07 +00:00
## Summary Use `saturating_add` for the three additions in the observer frame-size estimate. `serialized_len` returns `usize::MAX` on a serialization error; ordinary addition can panic in debug builds or wrap in release builds. Saturation keeps that estimate above the plaintext limit, so the next event stays queued. This is defensive hardening. The current empty envelope contains only JSON-safe fields, so a normal event cannot trigger that serialization error. ### Related issue Follow-up to #9483, addressing [this review suggestion](https://github.com/block/buzz/pull/9483#discussion_r4569450055). No duplicate issue or PR found. ### Testing Manually ran `observer::packing_tests::publish_queue_drain_probe --exact --ignored --nocapture` on the rebuilt debug test executable. All 10,000 events drained in order into 30 frames within the byte limit, with zero pending bytes. To reproduce: ```sh cargo test -p buzz-acp --lib observer::packing_tests::publish_queue_drain_probe -- --exact --ignored --nocapture ``` Generated with AI assistance Signed-off-by: Sanket Kanjalkar <sanketk@squareup.com> Co-authored-by: Codex <codex@openai.com>