diff --git a/js/net/src/flate/codec.test.ts b/js/net/src/flate/codec.test.ts index 397fe7c38b5..9263e419fdc 100644 --- a/js/net/src/flate/codec.test.ts +++ b/js/net/src/flate/codec.test.ts @@ -60,3 +60,11 @@ test("final blocks, malformed input, and a decoder already failed are refused", expect(() => decoder.frame(new Uint8Array(64).fill(0xff), 64)).toThrow(); expect(() => decoder.frame(new Uint8Array(), 0)).toThrow(/already failed/); }); + +test("incompressible input stays within the worst-case bound, across stored-block boundaries", () => { + const encoder = new Encoder(); + for (const size of [1, 4095, 4096, 16383, 16384, 16385, 65536, 100_003]) { + const payload = crypto.getRandomValues(new Uint8Array(size)); + expect(encoder.frame(payload).length).toBeLessThanOrEqual(Encoder.bound(size)); + } +}); diff --git a/js/net/src/group.test.ts b/js/net/src/group.test.ts index b575891176e..1206ef5150e 100644 --- a/js/net/src/group.test.ts +++ b/js/net/src/group.test.ts @@ -535,22 +535,20 @@ test("a plain frame has no size cap, while a compressed one keeps its whole-fram compressed.finish(); }); -// Quarantined: flaky under load, see /quest/m0/test-flakes-2/compressed-frame-cap.md -test.skip("a compressed frame is refused unless its worst-case slice fits a peer's frame cap", async () => { +// The bound's soundness for incompressible input lives in flate/codec.test.ts; deflating 32 MiB of +// noise here would cost seconds under load. +test("a compressed frame is refused unless its worst-case slice fits a peer's frame cap", async () => { const MAX = 32 * 1024 * 1024; let largest = MAX; while (!encodable(largest)) largest--; const compressed = new Producer(0n); hooks.bindGroupCompression(compressed, true); const reader = compressed.consume(); - // High-entropy input expands under DEFLATE, so even the cap itself may not encode within it. + // Refused by size alone, even though zeros would compress far below the cap. expect(() => compressed.writeFrame({ payload: new Uint8Array(largest + 1) })).toThrow(FrameTooLarge); expect(() => compressed.createFrame({ size: largest + 1 })).toThrow(FrameTooLarge); - const payload = new Uint8Array(largest); - for (let i = 0; i < largest; i += 65536) crypto.getRandomValues(payload.subarray(i, i + 65536)); - compressed.writeFrame({ payload }); + compressed.writeFrame({ payload: new Uint8Array(largest) }); const read = await hooks.readGroupFrame(reader, true); - expect(read?.frame.payload.byteLength).toBeGreaterThan(largest); expect(read?.frame.payload.byteLength).toBeLessThanOrEqual(MAX); compressed.finish(); diff --git a/quest/m0/test-flakes-2/README.md b/quest/m0/test-flakes-2/README.md index 8e83f1a21a4..c2c7aa08ae4 100644 --- a/quest/m0/test-flakes-2/README.md +++ b/quest/m0/test-flakes-2/README.md @@ -242,7 +242,6 @@ 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 - [bench/relay.test.py's stream-transport test gets a port free for TCP and UDP](/quest/m0/test-flakes-2/relay-port-pair.md) - the test binds TCP and UDP to one number free in both, so parallel checks can't collide with it -- [js/net's compressed-frame cap test holds up under load](/quest/m0/test-flakes-2/compressed-frame-cap.md) - the cap is proven without a 32 MiB payload, and its `test.skip` is removed - [js/net's lite-07 re-dropped re-offer test holds up under load](/quest/m0/test-flakes-2/redropped-reoffer.md) - update 3 is ordered before the re-offer opens by an event, not a yield count, and its `test.skip` is removed - [moq-net's random-mesh withdrawal tests fit the gate](/quest/m0/test-flakes-2/mesh-withdraw-runtime.md) - the 200-seed mesh tests cost seconds of CPU, and their `#[ignore]` 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 diff --git a/quest/m0/test-flakes-2/compressed-frame-cap.md b/quest/m0/test-flakes-2/compressed-frame-cap.md deleted file mode 100644 index 487df9e9340..00000000000 --- a/quest/m0/test-flakes-2/compressed-frame-cap.md +++ /dev/null @@ -1,27 +0,0 @@ -# [S] js/net's compressed-frame cap test holds up under load - -## Goal - -`js/net/src/group.test.ts`'s "a compressed frame is refused unless its -worst-case slice fits a peer's frame cap" passes on a loaded host, and its -`test.skip` is removed. It still proves the cap: a frame whose worst-case -slice exceeds the peer's cap is refused, and one that fits is accepted. - -## Plan - -Planned 2026-11-09 (maintainer, /quest-complete), under the repository's -flaky-test rule. Quarantined by -[moq-dev/moq#8333](https://github.com/moq-dev/moq/pull/8333) after the -whole `js/net` package failed it 2 of 30 times under 48 CPU burners on 24 -cores, first seen in [moq-dev/moq#8326](https://github.com/moq-dev/moq/pull/8326)'s -loaded runs. - -The failure is bun's per-test limit ("timed out after 5000ms", at 5840 ms and -10442 ms). Alone it takes about 0.85 s: it deflates and inflates a random -payload of almost 32 MiB, so the CPU work, not a race, runs past the limit -under load. This resembles the flate tail-shed test fixed in -[moq-dev/moq#8137](https://github.com/moq-dev/moq/pull/8137). Prove the cap -with a payload sized relative to a small cap (or a cap the test sets low) -rather than a full-size one; never raise the timeout. - -Public API: none. Wire: none.