Skip to content

remove 2 debug_asserts#3478

Open
jesup wants to merge 2 commits intousers/jesup/datagram_max_sizefrom
users/jesup/cleanup_asserts
Open

remove 2 debug_asserts#3478
jesup wants to merge 2 commits intousers/jesup/datagram_max_sizefrom
users/jesup/cleanup_asserts

Conversation

@jesup
Copy link
Copy Markdown
Member

@jesup jesup commented Mar 16, 2026

Remove a debug assert that could cause debug builds to fail in a race condition, plus one that should never happen

Copilot AI review requested due to automatic review settings March 16, 2026 05:00
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes two debug_assert!s in the extended CONNECT (WebTransport / CONNECT-UDP) session code to avoid debug-build failures in situations where those asserts can be reached (race/state transitions) or where the path should be unreachable.

Changes:

  • WebTransportSession::write_datagram_capsule() now returns Err(Error::Unavailable) instead of unconditionally Ok(()) with a failing debug_assert!.
  • Session::send_datagram() no longer fires a debug_assert!(false) when called in a non-Active state (it already returns Err(Error::Unavailable)).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
neqo-http3/src/features/extended_connect/webtransport_session.rs Replace an unconditional failing debug assert in the DATAGRAM capsule path with a concrete error return.
neqo-http3/src/features/extended_connect/session.rs Remove a debug assert in send_datagram() that could trip during non-Active state transitions while preserving the existing error behavior.

Comment on lines -422 to +424
debug_assert!(
false,
"[{self}] WebTransport does not support datagram capsules."
);
Ok(())
// WebTransport uses QUIC datagrams, not HTTP DATAGRAM Capsules.
// datagram_capsule_support() returns false so this should never be called.
Err(Error::Unavailable)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain how you are hitting this debug_assert?

webtransport::Session::datagram_capsule_support always returns false.

fn datagram_capsule_support(&self) -> bool {
// HTTP/3 WebTransport requires QUIC datagram support. In other words,
// HTTP/3 WebTransport never falls back to HTTP datagram capsules.
//
// > WebTransport over HTTP/3 also requires support for QUIC datagrams.
// > To indicate support, both the client and the server send a
// > max_datagram_frame_size transport parameter with a value greater than
// > 0 (see Section 3 of [QUIC-DATAGRAM]).
//
// <https://www.ietf.org/archive/id/draft-ietf-webtrans-http3-14.html#section-3.1>
false
}

Thus webtransport::Session::write_datagram_capsule should enver be called.

if conn.remote_datagram_size() == 0 && self.protocol.datagram_capsule_support() {
qtrace!("[{self}] remote_datagram_size is 0, trying HTTP DATAGRAM Capsule");
self.protocol.write_datagram_capsule(
&mut self.control_stream_send,
conn,
buf,
now,
)?;
return Ok((true, None));

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not hitting it. This shouldn't be possible at the moment, but if some future change (accidentally) changed that, returning an error would be better I think

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but if some future change (accidentally) changed that

In that case it would panic in debug mode, thus alerting us of the bug, and return an error in release mode, thus not causing harm. In other words, please keep this as is.

qtrace!("[{self}] send_datagram state={:?}", self.state);
if self.state != State::Active {
qdebug!("[{self}]: cannot send datagram in {:?} state.", self.state);
debug_assert!(false);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@jesup jesup force-pushed the users/jesup/cleanup_asserts branch from 6978589 to b5a260e Compare March 17, 2026 14:05
@jesup jesup force-pushed the users/jesup/datagram_max_size branch 2 times, most recently from 761c9f7 to d9cc0a9 Compare March 17, 2026 15:17
@mxinden
Copy link
Copy Markdown
Member

mxinden commented Mar 25, 2026

@jesup please see my response above. In addition, I believe you accidentally included unrelated changes in this pull request.

@larseggert larseggert added the needs-rebase PR needs rebasing before it can be merged. label Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-rebase PR needs rebasing before it can be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants