Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 0 additions & 34 deletions quest/m0/nightly/lite07-route-hang.md

This file was deleted.

28 changes: 28 additions & 0 deletions quest/m0/nightly/resume-history-control.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# [M] The browser resume-history control releases its last route

## Goal

The browser bench smoke's `resume-history` microbenchmark stops failing its control
intermittently on Nightly: once every front concludes and the serving route ends,
nothing of that route stays reachable. The cause is found and fixed at the root, with
a deterministic test that fails without the fix.

## Plan

Seen on Nightly runs
[43601796176](https://github.com/moq-dev/moq/actions/runs/43601796176) (2026-11-14,
"8 fronts, 1 names, 2 routes, churn, subscribe") and
[44127032469](https://github.com/moq-dev/moq/actions/runs/44127032469) (2026-11-17,
"8 fronts, 1 names, 2 routes, stable, fetch"), each with "the control kept
{"sessions":1,"transports":1,"broadcasts":8,"bytes":0} after concluding": the serving
route's client session, its transport, and its 8 broadcast handles. The 11-15 and
11-16 runs passed. Split out of the lite-07 route hang quest: the bench speaks
lite-06 (`ALPN_06`) and shares no cause with the lite-07 hangs.

It did not reproduce locally: three runs of
`bun micro.ts --bench resume-history --rounds 4 current=../.. aa=../..` in Chrome,
about 36 full sweeps, all passed. `drain` in `js/net/bench/resume-history.ts` returns
once two consecutive collections count the same, so teardown still pending on a host
task or a real-time timer after `conclude` would read as kept on a slower runner.
Trace what still references the client session after `conclude` (a heap snapshot
from the failing case) before changing the harness.
7 changes: 4 additions & 3 deletions rs/moq-net/benches/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -752,9 +752,10 @@ impl<B: Backend> Cluster<B> {
let (origin, pool) = self.origin(CLIENT_CACHE);
let mut options = MockConnectOptions::new(self.version);
options.transport.stream_buffer = self.window;
// Draft 22, the one IETF version here, keeps its SETUP stream open beside the groups.
options.transport.max_concurrent_uni_streams =
self.credit.map(|credit| credit + usize::from(!self.version.is_lite()));
// Draft 22 keeps its SETUP stream open beside the groups, and moq-lite-07 the
// relay's Announce Stream: neither may take the one grant the groups share.
let persistent = !self.version.is_lite() || self.version.as_str() == "moq-lite-07-wip";
options.transport.max_concurrent_uni_streams = self.credit.map(|credit| credit + usize::from(persistent));
options.client_discovers_all = self.discovers_all;
// Hidden included, as the dash's `.stats/` scope sees its subtree.
options.server_publish = Some(B::origin(&self.relays[relay]).consume().with_hidden(true));
Expand Down
64 changes: 64 additions & 0 deletions rs/moq-net/src/lite/subscriber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9330,6 +9330,70 @@ mod tests {
);
}

/// A grant that widens to cover a claim the answer already held back sends it at once,
/// though the node queues nothing behind it to flush it out.
#[kio::test]
async fn a_widened_grant_flushes_the_claim_it_shows() {
use crate::model::ProduceTest as _;
const VERSION: Version = Version::Lite07;
let publish = origin::Config::new(std::num::NonZeroU64::new(2).unwrap()).produce();
let route = publish.route("room", crate::origin::RouteOptions::hidden()).unwrap();
route.announce().unwrap();
// The peer asks for the whole tree, hidden paths included.
let request = |w: &mut crate::coding::Encoder<'_>| {
lite::AnnounceBroadcast::Request {
more: false,
remove: Vec::new(),
add: vec![(Path::empty(), true)],
}
.encode(w, VERSION)
.unwrap()
};
let session = crate::lite::test_transport::ScriptedSession::new(announce_script(VERSION, &[&request]));
// Only the half answering the peer is limited, so a change to it is all that happens.
let auth = crate::auth::Link::new(false);
auth.handle().authorize(&crate::auth::Grant::default());
let subscriber = Subscriber::new(SubscriberConfig {
runtime: crate::time::sim(),
session: crate::driver::Transport::new(session.clone()),
origin: origin::Config::new(std::num::NonZeroU64::new(1).unwrap()).produce(),
recv_bandwidth: None,
version: VERSION,
peer_setup: crate::lite::PeerSetup::new(false, crate::transport::Address::Setup),
cost: Some(1),
peer_node: None,
going_away: Default::default(),
auth: crate::auth::Link::new(false),
});
subscriber.peer_setup.set(lite::Setup::default()).unwrap();
let recv = crate::transport::boxed::RecvStream::new(session.recv());
let _ = (subscriber.announce_streams).try_push(route_stream::Reader::new(recv, VERSION));
let mut routes = route_stream::RouteStream::new(
subscriber.clone(),
route_stream::Publish {
origin: publish.consume(),
auth: auth.clone(),
withdrawal: Default::default(),
routing: false,
},
);
let written = || session.log.writes.lock().unwrap().len();
// Run until everything parks: the request answered, the claim held back.
let settled = kio::clock::timeout(
std::time::Duration::from_millis(1),
kio::wait(|waiter| routes.poll(waiter).map(|err| panic!("{err:?}"))),
)
.await;
assert!(settled.is_err(), "the session ended");
let held = written();

// The grant change is the one wakeup: the pass it runs must send what it shows,
// since nothing else is queued to wake the session again.
auth.handle().authorize(&crate::auth::Grant::all());
assert!(routes.poll(&kio::Waiter::noop()).is_pending());
assert!(written() > held, "the claim the grant now shows stayed buffered");
}

/// A peer streaming announces gets a budget of them read per poll, so the session's
/// other tasks run between them, and the announce behind the flood still arrives.
#[kio::test]
Expand Down
5 changes: 5 additions & 0 deletions rs/moq-net/src/lite/subscriber/route_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,11 @@ impl Running {
match self.answer.poll_mounts(&mut self.writer, waiter) {
Poll::Ready(res) => res?,
Poll::Pending => {
// A grant change can buffer claims with nothing queued behind them, and the
// wakeup that brought it is spent: flush before resting.
if matches!(self.sending, Sending::Open | Sending::Ending) && !self.writer.is_flushed() {
continue;
}
// Everything the node queued is served, so what the peer synced shows.
self.routed.release();
break;
Expand Down
13 changes: 5 additions & 8 deletions rs/moq-relay/benches/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,11 @@ impl Fixture {
let (send, mut receive) = tokio::sync::mpsc::unbounded_channel();
let decider = tokio::spawn(async move {
while let Some(admission) = admissions.next().await {
let prefix = admission
.request
.query
.as_deref()
.unwrap_or("initial")
.strip_prefix("jwt=")
.unwrap_or("initial")
.to_owned();
// An in-band token arrives as the request's token; the connection has none.
let prefix = match &admission.request.token {
Some(token) => String::from_utf8(token.value.clone()).unwrap(),
None => "initial".to_owned(),
};
let (producer, consumer) = lease::Producer::new(grant(&prefix));
admission.grant(consumer);
if send.send((prefix, producer)).is_err() {
Expand Down