Skip to content

fix(watch): a buffered audio head waits at most the max delay (backport #9267) - #9273

Open
kixelated wants to merge 1 commit into
releasefrom
fix/watch-order-hold-expiry-release
Open

kixelated wants to merge 1 commit into
releasefrom
fix/watch-order-hold-expiry-release

Conversation

@kixelated

@kixelated kixelated commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

A buffered subscription's audio Order holds the head until it's complete: a newer group arrives, the first group runs past the floor, or the held timestamps span the max delay. All three wait on timestamps advancing. A publisher that repeats one timestamp, or on release keeps sending older groups within that span, never triggers any of them. A viewer's tab keeps every frame it receives.

Approach

Port of moq-dev/moq#9267, reading Time.Micro.now() since release's js/watch predates @moq/clock.

Do as Rust's start gate in moq-audio does ("a packet waits at most the hold, which bounds what the gate keeps by arrival time, whatever the timestamps say"): the head is also released once it has waited the max delay since its first frame arrived, read from @moq/clock. What the hold keeps is then bounded by what the network delivers in that time, with no new constant.

The bound is the max delay rather than the floor: a zero floor still holds the head for its older groups, and every existing release path is unchanged.

Impact

  • No public API or wire change.

Validation

  • New Order test: 100 frames repeating one timestamp stay held until the manual clock reaches the max delay, then release together. It fails without the wall-clock release.
  • The existing Order tests now run on a mocked Time.Micro.now(), since the hold reads the time.
  • @moq/watch tests (272 pass), tsc --noEmit, and biome pass in the dev shell.
  • Not run in a browser.

Caused by

  • moq-dev/moq#6549 - added the hold, releasing it only as timestamps advance (found by reviewer)

Alternatives

  • Treat a non-advancing frame as a publisher violation and release the hold. Bounds repeats within a group but not 1 µs steps; the arrival-time bound covers both.
  • Cap the held frames or bytes. A constant, and codec-specific.

Follow-ups

None.

Models

Size: XS
Implementer: Claude Code, claude-opus-5-5, unknown effort

(Written by Claude Opus 5.5)

🤖 Generated with Claude Code

Review

Rewritten by quest review after each round.

  • Head: f5e3b14

  • Base: origin/release at 17afa89

  • Risk: medium, the base has no RISK.md to name what is always high or customer-facing, so every change is medium

  • Classified: medium by default

  • Reviewer: Codex, gpt-6.1-sol, medium effort

  • Session: 01a1fbab-a63c-79c0-b2bc-293a1105b46c, round 1

  • Score: 9/10, No actionable defects were found in the focused ordering and time-conversion change, which includes a mocked-clock regression test, though tests were not run as instructed.

  • Rounds: 1; first round 0; findings 0: fixed 0, refuted 0, open 0

  • Findings: none

#9267)

The hold released only as timestamps advanced, so a publisher repeating
one timestamp, or sending older groups within the span, grew it without
bound. Release it once it has waited the max delay too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated
kixelated marked this pull request as ready for review November 21, 2026 01:14
@kixelated
kixelated marked this pull request as draft November 21, 2026 01:14
@kixelated
kixelated marked this pull request as ready for review November 21, 2026 01:15

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Approach: sound. It bounds the held audio head by arrival time, which covers repeated timestamps and older-group floods that never advance the existing release conditions.

Reviewed changes

Reviewed the single backport commit against release.

  • Wall-clock release in Order.push: the head records arrived from Time.Micro.now() when its first frame arrives, and flush() fires once waited >= hold.maxDelay. The other release paths are unchanged.
  • Test: a new case pushes 100 repeated-timestamp frames, then checks the head is held at 999 µs and released together (102 frames) at 1000 µs. Existing tests now run against a mocked Time.Micro.now().

I checked that Time.Micro.now() exists on release (js/net/src/time.ts) and that @moq/net is already declared in js/watch/package.json. #first is only set under the hold and flush() ends the hold, so the arrived stamp can't go stale. I did not run the tests.

Pullfrog  | View workflow run | Using claude-sonnet-5-5 | 𝕏

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant