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
61 changes: 59 additions & 2 deletions js/net/src/ietf/request_stream.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect, spyOn, test } from "bun:test";
import { expect, mock, spyOn, test } from "bun:test";
import { Manual, Milli, Nano } from "@moq/clock";
import { ProtocolViolation, SessionCode, StreamCode, StreamError } from "../error.ts";
import { NoStreamCredit, ProtocolViolation, SessionCode, StreamCode, StreamError } from "../error.ts";
import { Reader, Stream } from "../stream.ts";
import { Deadline, REQUEST_TIMEOUT_MS } from "../util/deadline.ts";
import * as Varint from "../varint.ts";
Expand Down Expand Up @@ -196,3 +196,60 @@ test("a request's deadline ends it through the request, so later ends do nothing
installed.close();
}
});

test("a request opening after its deadline is aborted through its owner once and never sends", async () => {
const clock = new Manual();
const installed = clock.install();
const owners: RequestStream[] = [];
const abort = RequestStream.prototype.abort;
const ownerAborts = spyOn(RequestStream.prototype, "abort").mockImplementation(function (
this: RequestStream,
err: unknown,
) {
owners.push(this);
abort.call(this, err);
});
try {
const write = mock((_chunk: Uint8Array) => {});
const stream = new Stream({
readable: new ReadableStream<Uint8Array>(),
writable: new WritableStream<Uint8Array>({ write }),
version: Version.DRAFT_18,
});
const aborts = spyOn(stream, "abort");
const opening = Promise.withResolvers<Stream>();
const session = {
version: Version.DRAFT_18,
client: true,
openBi: () => opening.promise,
} as unknown as Session;
const deadline = new Deadline();
const send = mock((request: RequestStream) => request.writer.u8(1));
const sending = RequestStream.open(session, deadline).then(send);
const answer = deadline.wait(sending).catch((e: unknown) => e);
await clock.advance(Nano.fromMilli(Milli(REQUEST_TIMEOUT_MS)));
const err = await answer;
expect(err).toBeInstanceOf(NoStreamCredit);
expect(ownerAborts).not.toHaveBeenCalled();
expect(aborts).not.toHaveBeenCalled();

opening.resolve(stream);
await expect(sending).rejects.toBe(err);
expect(ownerAborts).toHaveBeenCalledTimes(1);
expect(ownerAborts.mock.calls[0]?.[0]).toBe(err);
const [request] = owners;
expect(request).toBeInstanceOf(RequestStream);
await request.ended;

// The caller's cleanup cannot reset the late stream a second time.
request.abort(new Error("abandoned"));
request.close();
expect(aborts).toHaveBeenCalledTimes(1);
expect(aborts.mock.calls[0]?.[0]).toBe(err as NoStreamCredit);
expect(send).not.toHaveBeenCalled();
expect(write).not.toHaveBeenCalled();
} finally {
ownerAborts.mockRestore();
installed.close();
}
});
1 change: 0 additions & 1 deletion quest/m1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ per-frame CPU growth since #5926.
- [A cancelled MoqTrackDemand wait never loses the next change](/quest/m1/demand-cancel-race.md) - cancelling a `MoqTrackDemand::wanted_changed` call, from any binding, never consumes a demand change
- [moq-ffi reports an unsupported media configuration as a typed error](/quest/m1/ffi-unsupported-config.md) - `MoqAudioConsumer::subscribe` and the matching video subscribe fail with a typed "unsupported configuration" error
- [A live keyframe interval change never outruns the declared HLS duration](/quest/m1/js-hls-keyframe-duration.md) - raising a live keyframe interval, even to infinite, never pushes a segment past the declared HLS target duration, and the browser interop cell asserts the catalog `hls` field
- [A request stream that opens after its deadline is aborted once and never sends](/quest/m1/js-request-deadline.md) - A `@moq/net` IETF request whose stream finishes opening only after its deadline fired is aborted exactly once, through its `RequestStream`, and never writes its request
- [One Ed25519 public key type with one z-base-32 codec](/quest/m1/mesh-key-codec.md) - `moq_auth::mesh::EndpointId` is merged into `moq_sign::PublicKey`
- [moqsink reports track demand only once the track is in the catalog](/quest/m1/moqsink-demand-catalog.md) - A `moqsink` request pad's `track-demand` stays null until its track is listed in the published catalog, and only then reports `wanted`
- [A discontinuity before the first frame keeps the init's parameter sets](/quest/m1/mux-discontinuity-headers.md) - an avc3, hev1, or av01 track that marks a discontinuity before its first frame still publishes that first keyframe with its init's parameter sets
Expand Down
29 changes: 0 additions & 29 deletions quest/m1/js-request-deadline.md

This file was deleted.