diff --git a/noq-proto/src/connection/mod.rs b/noq-proto/src/connection/mod.rs index 1bd63968c..b1ca7ff31 100644 --- a/noq-proto/src/connection/mod.rs +++ b/noq-proto/src/connection/mod.rs @@ -7644,6 +7644,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 59bab5208..0b26145a6 100644 --- a/noq-proto/src/connection/packet_builder.rs +++ b/noq-proto/src/connection/packet_builder.rs @@ -331,6 +331,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();