From 560e66594514c11d59619e01faabb52d85a8d450 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Wed, 18 Nov 2026 03:51:08 -0800 Subject: [PATCH 1/2] chore(quest): claim quest/m0/test-flakes-3/c-server-accepts-session.md Quest-Claim: 08774965aafe6b7a From 1c0c161d281d439bef6c65ecb76d395c00790d11 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Wed, 18 Nov 2026 04:42:49 -0800 Subject: [PATCH 2/2] test(libmoq): session tests' comments follow the credential rule that fixed the close flake The client's close returned SESSION_NOT_FOUND when the server closed the accepted session first: before #9038 a session closed within 1s of uptime ended the reconnect loop, racing the test's close. #9038 establishes a session once its SETUP is answered, so the client now redials. Drop the comments that still describe the old rule, and the finished quest. Co-Authored-By: Claude Opus 5.5 --- .../test-flakes-3/c-server-accepts-session.md | 32 ------------------- rs/libmoq/src/test.rs | 12 +++---- rs/libmoq/src/test/parity.rs | 1 - 3 files changed, 6 insertions(+), 39 deletions(-) delete mode 100644 quest/m0/test-flakes-3/c-server-accepts-session.md diff --git a/quest/m0/test-flakes-3/c-server-accepts-session.md b/quest/m0/test-flakes-3/c-server-accepts-session.md deleted file mode 100644 index e21e7efe3f..0000000000 --- a/quest/m0/test-flakes-3/c-server-accepts-session.md +++ /dev/null @@ -1,32 +0,0 @@ -# [S] libmoq's session tests close their client after the server did - -## Goal - -`rs/libmoq/src/test.rs::server_accepts_a_session` and `rs/libmoq/src/test/parity.rs::session_tokens_and_grants` pass every run. - -## Plan - -Found 2026-11-16 by `just check` on -[moq-dev/moq#8964](https://github.com/moq-dev/moq/pull/8964), whose change -does not touch libmoq's session or server code. Running it alone with -`cargo nextest run -p libmoq server_accepts_a_session` fails 4 of 12 runs at -main 73d65edbf7: `moq_session_close(client)`, after the accepted session -closed and its tail drained, returns -21 where the test expects 0. - -The client's session likely already ended on its own once the server side -closed, so its id is gone by the time the test closes it. That release is the -contract: `rs/libmoq/src/session.rs` removes a session's entry before its -terminal `CLOSED` callback, so `moq_session_close` on a handle whose terminal -callback has fired (or is about to) returns a negative code. Find why the client -ends: if a dialed client is meant to keep reconnecting after its server closes -the accepted session, its early end is a library bug, fixed there with a -regression test. Otherwise the test changes: it waits on the client's terminal -callback and drops the `moq_session_close(client) == 0` assertion, or asserts -the close is negative after that callback, as `moq_server_close` already does. - -`session_tokens_and_grants` has the same shape: it closes the accepted session, -waits for its terminal callback, then asserts `moq_session_close(client) == 0` -(`parity.rs:530`). It fails 3 of 8 runs alone at main a79bbae919, found while -merging main into #8964. Fix both the same way. - -Public API: none. Wire: none. diff --git a/rs/libmoq/src/test.rs b/rs/libmoq/src/test.rs index a818a44dcf..79c81e0463 100644 --- a/rs/libmoq/src/test.rs +++ b/rs/libmoq/src/test.rs @@ -8524,8 +8524,7 @@ fn announce_route_crosses_a_relay_session() { assert_eq!(moq_origin_announced_cancel(task), 0); assert_eq!(announced_cb.recv_announce_terminal(), 0); - // Each client first: closed by its peer before it was healthy, it would end on its own. - // Its peer gone, the accepted session ends too. + // Each client's close ends its accepted session too. for (client, client_cb, accepted, accepted_cb) in [ (downstream_client, &downstream_client_cb, downstream, &downstream_cb), (upstream_client, &upstream_client_cb, upstream, &upstream_cb), @@ -8641,7 +8640,6 @@ fn a_minted_instance_pins_request_and_follow() { assert_eq!(moq_origin_announced_free(announced), 0); assert_eq!(moq_origin_announced_cancel(task), 0); assert_eq!(announced_cb.recv_announce_terminal(), 0); - // The client first: closed by its peer before it was healthy, it would end on its own. assert_eq!(moq_session_close(client), 0); client_cb.recv_terminal(); // Its peer gone, the accepted session ends too, which releases its handle. @@ -8758,6 +8756,8 @@ fn server_accepts_a_session() { assert_eq!((terminal.failure, terminal.connects), (0, 1)); assert!(moq_consume_track_cancel(consumer) < 0, "the consumer ended"); assert_eq!(moq_consume_close(consumed), 0); + // The server answered the client's credential, so its close leaves the client redialing + // rather than ended, and the handle is still there to close. assert_eq!(moq_session_close(client), 0); client_cb.recv_terminal(); @@ -8793,9 +8793,9 @@ fn server_rejects_a_session() { assert_eq!(moq_session_request_reject(request, 403), 0); assert!(moq_session_request_free(request) < 0, "reject consumes the request"); - // The rejection closes a session the transport already established, so the client - // sees it connect first. Refused before it was healthy, the session then ends with the - // rejection rather than redialing, as a refused first dial does. + // The rejection closes a session the transport already established. Closed before the + // server answered its credential, the session ends with the rejection rather than + // redialing, as a refused first dial does. let terminal = client_cb.recv_terminal(); let protocol = terminal.protocol.expect("the terminal snapshot names the rejection"); assert_eq!(protocol.scope, moq_error_scope::MOQ_ERROR_SCOPE_SESSION as u32); diff --git a/rs/libmoq/src/test/parity.rs b/rs/libmoq/src/test/parity.rs index dfe8bd8668..3b40343cb2 100644 --- a/rs/libmoq/src/test/parity.rs +++ b/rs/libmoq/src/test/parity.rs @@ -270,7 +270,6 @@ fn session_tokens_and_grants() { let _watcher = id(unsafe { moq_session_grants(client, Some(channel_callback), ending.ptr) }); assert_eq!(moq_grant_free(id(ending.recv())), 0); - // The client first: closed by its peer before it was healthy, it would end on its own. assert_eq!(moq_session_close(client), 0); client_cb.recv_terminal(); // Its peer gone, the accepted session ends too, which releases its handle.