Skip to content

test(publish): run the audio delay test on a mock clock - #4850

Closed
kixelated wants to merge 2 commits into
mainfrom
quest/m1/test-flakes-2/publish-audio-clock
Closed

kixelated wants to merge 2 commits into
mainfrom
quest/m1/test-flakes-2/publish-audio-clock

Conversation

@kixelated

Copy link
Copy Markdown
Collaborator

Problem

The js/publish audio encoder test "a rendition trailing the broadcast's earliest advertises delay" reads performance.now() and subtracts 100ms. Early in the process that stamp is negative. Encoding rejects it, so the test fails when its file runs alone.

Approach

Freeze performance.now() at 200ms for that test and restore it afterward. Capture stamps stay nonnegative, and the advertised delay is exactly 100ms. Deletes the finished quest.

Impact

  • No public API change.
  • No wire change.

Alternatives

  • Keep the wall clock and skip the case until performance.now() is past 100ms. That still depends on process age.
  • Clamp negative stamps in the encoder. The production clock does not go negative; the test was the bug.

Follow-ups

  • None. The rest of the test-flakes-2 line is unchanged.

(Written by Grok 4.7)

kixelated and others added 2 commits October 5, 2026 13:36
Co-Authored-By: Grok 4.7 <noreply@x.ai>
The delay case subtracts 100ms from performance.now(). Early in the process that stamp is negative, and encoding rejects it, so the test fails when its file runs alone.

Co-Authored-By: Grok 4.7 <noreply@x.ai>
@kixelated

Copy link
Copy Markdown
Collaborator Author

The delay test failed alone because performance.now() was about 2ms at process start, so "captured 100ms ago" encoded as a negative timestamp and the frame write threw. It now freezes that clock at 200ms. just check passed. No API or wire change. Left as a draft.

(Written by Grok 4.7)

@kixelated
kixelated marked this pull request as ready for review October 6, 2026 12:32
@kixelated

Copy link
Copy Markdown
Collaborator Author

Closing this as superseded by #4653, which is on main. That PR deleted quest/m1/test-flakes-2/publish-audio-clock.md and js/publish/src/audio/encoder.test.ts already spies on performance.now with mockReturnValue(200). The only leftover difference is assertion style (u53(100) versus toMatchObject({ delay: 100 })), and the behavior is the same.

(Written by Grok 4.7)

@kixelated kixelated closed this Oct 6, 2026
@kixelated
kixelated deleted the quest/m1/test-flakes-2/publish-audio-clock branch October 8, 2026 07:06
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