Repository navigation
fix(net): resolve subscription starts from max latency #3181
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
Changes from all commits
5d9d29f
2e60050
30efd38
3b162ca
7753bba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ import { type Dispose, Signal } from "@moq/signals"; | |
| import type * as broadcast from "../broadcast.ts"; | ||
| import { error, reason } from "../error.ts"; | ||
| import type * as group from "../group.ts"; | ||
| import { hooks } from "../internal.ts"; | ||
| import type { Origin } from "../origin.ts"; | ||
| import * as Path from "../path.ts"; | ||
| import { type Stream, Writer } from "../stream.ts"; | ||
|
|
@@ -278,8 +279,6 @@ export class Publisher { | |
| startGroup: msg.startGroup, | ||
| endGroup: msg.endGroup, | ||
| }); | ||
|
Comment on lines
279
to
281
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When a lite-03 through lite-05 peer sends a nonzero AGENTS.md reference: AGENTS.md:L207-L207 Useful? React with 👍 / 👎. |
||
| const startGroup = msg.startGroup ?? track.latest(); | ||
| if (startGroup !== undefined) track.startAt(startGroup); | ||
| track.endAt(msg.endGroup); | ||
|
|
||
| // The best-effort datagram loop, started once serving begins. It parks when the | ||
|
|
@@ -316,7 +315,8 @@ export class Publisher { | |
|
|
||
| console.debug(`publish ok: broadcast=${msg.broadcast} track=${track.name}`); | ||
|
|
||
| const serving = this.#runTrack(msg.id, msg.broadcast, track, stream.writer, timescale); | ||
| const range: { start?: number } = {}; | ||
| const serving = this.#runTrack(msg.id, msg.broadcast, track, stream.writer, timescale, range); | ||
|
|
||
| // Serve datagrams concurrently with groups whenever the transport carries them | ||
| // (the writer exists iff so). No group fallback: otherwise they simply aren't sent. | ||
|
|
@@ -332,14 +332,21 @@ export class Publisher { | |
|
|
||
| if (result instanceof SubscribeUpdate) { | ||
| console.debug(`subscribe update: broadcast=${msg.broadcast} track=${track.name}`); | ||
| const previous = track.subscription.peek(); | ||
| track.update({ | ||
| priority: result.priority, | ||
| ordered: result.ordered, | ||
| latencyMax: result.maxLatency, | ||
| startGroup: result.startGroup, | ||
| endGroup: result.endGroup, | ||
| }); | ||
| if (result.startGroup !== undefined) track.startAt(result.startGroup); | ||
| if ( | ||
| previous?.latencyMax !== result.maxLatency || | ||
| previous.startGroup !== result.startGroup || | ||
| previous.endGroup !== result.endGroup | ||
| ) { | ||
| hooks.positionSubscriber(track, range.start); | ||
| } | ||
| track.endAt(result.endGroup); | ||
| } | ||
| } | ||
|
|
@@ -408,7 +415,14 @@ export class Publisher { | |
| * | ||
| * @internal | ||
| */ | ||
| async #runTrack(sub: bigint, broadcast: Path.Valid, track: track.Subscriber, stream: Writer, timescale: Timescale) { | ||
| async #runTrack( | ||
| sub: bigint, | ||
| broadcast: Path.Valid, | ||
| track: track.Subscriber, | ||
| stream: Writer, | ||
| timescale: Timescale, | ||
| range: { start?: number }, | ||
| ) { | ||
| // Lite-05+ resolves the range on the subscribe stream: SUBSCRIBE_START once the | ||
| // first group is known, SUBSCRIBE_END when the track finishes. | ||
| const emitRange = supportsTrackStream(this.version); | ||
|
|
@@ -453,6 +467,7 @@ export class Publisher { | |
|
|
||
| if (emitRange && !startSent) { | ||
| startSent = true; | ||
| range.start = group.sequence; | ||
| // SUBSCRIBE_START promises nothing below this sequence will be delivered. | ||
| // Arrival-order serving could later surface a straggler below the first | ||
| // group, so pin the floor to what was announced. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.