diff --git a/js/net/src/lite/datagram-tracks.test.ts b/js/net/src/lite/datagram-tracks.test.ts index a41c5bc877..444f5cc332 100644 --- a/js/net/src/lite/datagram-tracks.test.ts +++ b/js/net/src/lite/datagram-tracks.test.ts @@ -1,4 +1,5 @@ import { expect, onTestFinished, spyOn, test } from "bun:test"; +import { AsyncLocalStorage } from "node:async_hooks"; import * as clock from "@moq/clock"; import { yieldNow } from "@moq/clock"; import { Signal } from "@moq/signals"; @@ -478,23 +479,24 @@ 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]) { - // flaky: quest/m0/flaky/a-session-close-right-after-a-datagram-tracks-end-keeps-the-2.md - const testEnd = test.skipIf(alpn === ALPN_06); - testEnd(`${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 = defined(publication.broadcast.createDatagrams("audio")); publication.announce(); const pair = createMockTransportPair(alpn); + // Tags the client's tasks: the publisher, or an earlier test's session woken by a late host + // timer, also yields host tasks. + const clientTask = new AsyncLocalStorage(); const [client, server] = await Promise.all([ - connect({ url, transport: pair.client }), + clientTask.run(true, () => connect({ url, transport: pair.client })), accept({ url, transport: pair.server, publish: source.consume() }), ]); - const remote = wireOf(client).consume(path); - const reader = remote.datagrams("audio"); + const remote = clientTask.run(true, () => wireOf(client).consume(path)); + const reader = clientTask.run(true, () => remote.datagrams("audio")); reader.setPriority(5); - // Only the end's routing yields a host task after the finish below: the receive loop's - // budget never runs out here. + // Only the end's routing yields a client 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 | undefined; // Runs even when the test times out with a wait still pending. @@ -513,7 +515,7 @@ for (const alpn of [ALPN_05, ALPN_06, ALPN_07_WIP]) { const received = Promise.withResolvers(); const hostTask = clock.yieldNow; routing = spyOn(clock, "yieldNow").mockImplementation(() => { - received.resolve(); + if (clientTask.getStore()) received.resolve(); return hostTask(); }); datagrams.finish(); diff --git a/quest/m0/flaky/README.md b/quest/m0/flaky/README.md deleted file mode 100644 index 53e540b1e9..0000000000 --- a/quest/m0/flaky/README.md +++ /dev/null @@ -1,6 +0,0 @@ -# Fix disabled flaky tests - -## Goal - -Each disabled flaky test is fixed or deleted, with its skip removed when -fixed. Each quest here records the failures that led to its skip. diff --git a/quest/m0/flaky/a-session-close-right-after-a-datagram-tracks-end-keeps-the-2.md b/quest/m0/flaky/a-session-close-right-after-a-datagram-tracks-end-keeps-the-2.md deleted file mode 100644 index 189163a4af..0000000000 --- a/quest/m0/flaky/a-session-close-right-after-a-datagram-tracks-end-keeps-the-2.md +++ /dev/null @@ -1,12 +0,0 @@ -# [S] Fix the flaky test a-session-close-right-after-a-datagram-tracks-end-keeps-the - -## Goal - -Fix `@moq/net moq-lite-06: a session close right after a datagram tracks end keeps the end` so it passes reliably, or delete it, and remove its skip. -quest land watch disabled it after the land fixer judged it flaky in -more than one `merge_group` build. - -Failing jobs: - -- [Job 1](https://github.com/moq-dev/moq/actions/runs/44557764205/job/135678374099) -- [Job 2](https://github.com/moq-dev/moq/actions/runs/44566631708/job/135710065415)