diff --git a/noq-proto/src/connection/mod.rs b/noq-proto/src/connection/mod.rs index c708aa71f..4fbacff95 100644 --- a/noq-proto/src/connection/mod.rs +++ b/noq-proto/src/connection/mod.rs @@ -7575,6 +7575,11 @@ impl SentFrames { && self.retransmits.is_empty(streams) } + /// Returns whether the packet contains any frames at all + fn is_empty(&self, streams: &StreamsState) -> bool { + !self.non_retransmits && self.stream_frames.is_empty() && self.retransmits.is_empty(streams) + } + fn retransmits_mut(&mut self) -> &mut Retransmits { self.retransmits.get_or_create() } diff --git a/noq-proto/src/connection/packet_builder.rs b/noq-proto/src/connection/packet_builder.rs index dbee47e7f..2ad5ab3e5 100644 --- a/noq-proto/src/connection/packet_builder.rs +++ b/noq-proto/src/connection/packet_builder.rs @@ -327,6 +327,10 @@ impl<'a, 'b> PacketBuilder<'a, 'b> { self.buf.len() <= self.buf.datagram_max_offset() - self.tag_len, "packet exceeds maximum size" ); + debug_assert!( + !self.sent_frames.is_empty(&conn.streams), + "constructed empty packet" + ); let pad = self.buf.len() < self.min_size; if pad { let padding = self.min_size - self.buf.len();