Repository navigation
fix(net)!: preserve errors when closing unfinished work #6978
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7a0273e
chore(quest): claim quest/m1/cut-audit/js-close-cause.md
kixelated 41b7f96
fix(net)!: preserve errors when closing unfinished work
kixelated 229329c
test(hang): keep the stalled group live until duration skip
kixelated c8100b3
docs(quest): state the remaining local-close decision
kixelated cd29a43
Merge remote-tracking branch 'origin/main' into quest/m1/cut-audit/js…
kixelated File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| import { expect, test } from "bun:test"; | ||
| import { Producer as BroadcastProducer } from "./broadcast.ts"; | ||
| import { ProtocolViolation, SessionCode, StreamCode } from "./error.ts"; | ||
| import { hooks } from "./internal.ts"; | ||
| import { Connection } from "./lite/connection.ts"; | ||
| import { StreamId } from "./lite/stream.ts"; | ||
| import { ALPN_06, Version } from "./lite/version.ts"; | ||
| import { createMockTransportPair, textFrame } from "./mock.ts"; | ||
| import { Producer as OriginProducer } from "./origin.ts"; | ||
| import * as Path from "./path.ts"; | ||
| import { Stream } from "./stream.ts"; | ||
| import { Timescale } from "./time.ts"; | ||
| import { Producer as TrackProducer } from "./track.ts"; | ||
| import { wireOf } from "./wire.ts"; | ||
|
|
||
| for (const release of [false, true]) { | ||
| test(`${release ? "releasing" : "closing"} a track preserves finished groups and aborts its unfinished tail`, async () => { | ||
| const producer = new TrackProducer("video").accept({ timescale: Timescale.MILLI }); | ||
| const complete = producer.appendGroup(); | ||
| complete.writeFrame(textFrame("complete")); | ||
| complete.finish(); | ||
| const tail = producer.appendGroup(); | ||
| tail.writeFrame(textFrame("prefix")); | ||
| const finished = complete.consume(); | ||
| const unfinished = tail.consume(); | ||
| producer.finish(); | ||
| try { | ||
| if (release) hooks.releaseTrack(producer); | ||
| else producer.close(); | ||
| expect(await finished.readString()).toBe("complete"); | ||
| expect(await finished.readFrame()).toBeUndefined(); | ||
| expect(await unfinished.readString()).toBe("prefix"); | ||
| await expect(unfinished.readFrame()).rejects.toMatchObject({ code: StreamCode.Cancel }); | ||
| } finally { | ||
| finished.close(); | ||
| unfinished.close(); | ||
| producer.close(); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| test("an unanswered track request is refused with the dropped producer's error", async () => { | ||
| const broadcast = new BroadcastProducer(); | ||
| const requested = wireOf(broadcast).requested(); | ||
| const track = broadcast.track("absent").subscribe(); | ||
| await requested; | ||
| const info = track.info(); | ||
| broadcast.close(); | ||
| try { | ||
| await expect(info).rejects.toMatchObject({ code: StreamCode.Internal }); | ||
| expect(await track.closed).toMatchObject({ code: StreamCode.Internal }); | ||
| } finally { | ||
| track.close(); | ||
| } | ||
| }); | ||
|
|
||
| test("a lite protocol violation reaches the subscribed track and its open group", async () => { | ||
| const pair = createMockTransportPair(ALPN_06); | ||
| const origin = new OriginProducer(); | ||
| const publication = origin.createBroadcast(Path.from("room")); | ||
| publication.announce(); | ||
| const producer = publication.broadcast.createTrack("video", { timescale: Timescale.MILLI }); | ||
| producer.appendGroup().writeFrame(textFrame("prefix")); | ||
| const url = new URL("https://example.com"); | ||
| const client = new Connection({ url, quic: pair.client, version: Version.DRAFT_06 }); | ||
| const server = new Connection({ | ||
| url, | ||
| quic: pair.server, | ||
| version: Version.DRAFT_06, | ||
| publish: origin.consume(), | ||
| client: false, | ||
| }); | ||
| const broadcast = wireOf(client).consume(Path.from("room")); | ||
| const track = broadcast.track("video").subscribe(); | ||
| const group = await track.recvGroup(); | ||
| try { | ||
| expect(await group?.readString()).toBe("prefix"); | ||
| const duplicate = await Stream.open(pair.server, { version: Version.DRAFT_06 }); | ||
| await duplicate.writer.u53(StreamId.Session); | ||
| expect((await pair.client.closed).closeCode).toBe(SessionCode.ProtocolViolation); | ||
| expect(await track.closed).toBeInstanceOf(ProtocolViolation); | ||
| await expect(group?.readFrame()).rejects.toBeInstanceOf(ProtocolViolation); | ||
| } finally { | ||
| group?.close(); | ||
| track.close(); | ||
| broadcast.close(); | ||
| client.abort(); | ||
| server.abort(); | ||
| publication.broadcast.close(); | ||
| origin.close(); | ||
| } | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.