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
22 changes: 14 additions & 8 deletions js/net/src/lite/datagram-tracks.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { expect, onTestFinished, spyOn, test } from "bun:test";
import * as clock from "@moq/clock";
import { yieldNow } from "@moq/clock";
import { Signal } from "@moq/signals";
import { accept, connect } from "../connection/index.ts";
Expand Down Expand Up @@ -470,9 +471,7 @@ for (const alpn of [ALPN_05, ALPN_06, ALPN_07_WIP]) {
// A track's end waits a host task for the datagrams received with it. A session close in
// between finishes the track rather than cutting it off: the publisher already ended it.
for (const alpn of [ALPN_05, ALPN_06, ALPN_07_WIP]) {
// Quarantined: fails in the merge queue with "Session: remote error: 0" (lite-06 on #8280, lite-05 on
// #8276 after #8321 re-enabled it). /quest/m0/test-flakes-2/datagram-close-end.md
test.skip(`${alpn}: a session close right after a datagram track's end keeps the end`, async () => {
test(`${alpn}: a session close right after a datagram track's end keeps the end`, async () => {
const source = new Origin();
const publication = source.route(path, { hidden: true });
const datagrams = publication.broadcast.createDatagrams("audio");
Expand All @@ -485,13 +484,14 @@ for (const alpn of [ALPN_05, ALPN_06, ALPN_07_WIP]) {
const remote = wireOf(client).consume(path);
const reader = remote.datagrams("audio");
reader.setPriority(5);
// The end has to reach the client before the abort, and the mock delivers it in
// microtasks. A write-budget yield is a host task that the drain below can't advance,
// so under CPU load the publisher's answer could still be stalled when the abort lands.
// Only the end's routing yields a host task after the finish below: the receive loop's
// budget never runs out here.
const budget = spyOn(Budget.prototype, "poll").mockImplementation(() => undefined);
let routing: ReturnType<typeof spyOn> | undefined;
// Runs even when the test times out with a wait still pending.
onTestFinished(() => {
budget.mockRestore();
routing?.mockRestore();
reader.close();
remote.close();
client.abort();
Expand All @@ -500,9 +500,15 @@ for (const alpn of [ALPN_05, ALPN_06, ALPN_07_WIP]) {
});
await reader.info();
while (datagrams.priority.peek() !== 5) await datagrams.priority.changed();
// The client marks the end taken, then waits a host task to route what arrived with it.
const received = Promise.withResolvers<void>();
const hostTask = clock.yieldNow;
routing = spyOn(clock, "yieldNow").mockImplementation(() => {
received.resolve();
return hostTask();
});
datagrams.finish();
// The mock delivers the end in microtasks, all within this host task.
for (let i = 0; i < 10000; i++) await Promise.resolve();
await received.promise;
client.abort();
expect(await reader.recv()).toBeUndefined();
});
Expand Down
5 changes: 3 additions & 2 deletions quest/m0/test-flakes-2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,9 @@ Added 2026-11-09 (maintainer's standing rule that flakes join this epic):
`js/net`'s datagram session-close-after-end test again, whose lite-05 case
failed the merge queue for [moq-dev/moq#8276](https://github.com/moq-dev/moq/pull/8276)
after [moq-dev/moq#8321](https://github.com/moq-dev/moq/pull/8321) re-enabled it.
It is quarantined with `test.skip` for every version until its child fixes it.
The test now aborts once the client has recorded the end, signalled by the
subscriber's `yieldNow()`, and is re-enabled by
[moq-dev/moq#8357](https://github.com/moq-dev/moq/pull/8357).

Added 2026-11-09 (maintainer's standing rule that flakes join this epic):
moq-rs's Python socket test `test_tcp_rst_and_endpoint_close_are_errors`, whose
Expand All @@ -247,5 +249,4 @@ Public API: none. Wire: none.

- [Fallback playback](/quest/m0/test-flakes-2/ietf22-fallback.md) - a browser viewer follows a fallback within the media lane's bound without dropping its session
- [js/net's bandwidth sampling test holds up under load](/quest/m0/test-flakes-2/bandwidth-sampling.md) - the sampling test counts ticks without racing the mocked clock, and its `test.skip` is removed
- [js/net's datagram session-close-after-end test holds up under load](/quest/m0/test-flakes-2/datagram-close-end.md) - the abort is ordered after the end by an event the client observes, and its `test.skip` is removed
- [js/net's lite-07 datagram queue test holds up under load](/quest/m0/test-flakes-2/datagram-queues.md) - the test waits for the first track's queue instead of asserting at once, and its `test.skip` is removed
30 changes: 0 additions & 30 deletions quest/m0/test-flakes-2/datagram-close-end.md

This file was deleted.

Loading