Skip to content

test(moq-webrtc): a WHIP publisher past its cap keeps sending until it is closed - #9452

Merged
kixelated merged 1 commit into
mainfrom
fix/whip-cap-flaky-test
Nov 23, 2026
Merged

kixelated merged 1 commit into
mainfrom
fix/whip-cap-flaky-test

Conversation

@kixelated

@kixelated kixelated commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

tests::a_whip_publisher_past_its_cap_plus_burst_is_closed knocked two PRs out of the merge queue under host load (run 45089229485, run 45088080247), sitting out its full 10 s timeout with "the publisher past its cap stayed open: Elapsed".

The test sent a single 1000-byte Opus packet before the WHIP client connected. The client's egress subscribes with a 100 ms delay budget (MAX_DELAY in rs/moq-webrtc/src/egress.rs), and each Opus packet's group ends with the packet. So a client that connected more than 100 ms later skipped that group. The server then received no media, the cap never tripped, and the session stayed open. The cap enforcement itself is fine: it never saw a byte.

Approach

The source now sends live, the way the sibling tests' sources already do (Live, from moq-dev/moq#9275). It sends one 1000-byte packet every 20 ms until the session ends, so whenever the client connects, the next packet trips the 100-byte burst. Live::play's send loop becomes Live::until, which sends until any future resolves, and play is built on it.

I audited the sibling tests. The other tests that wait on media already use Live. a_capped_whip_publisher_is_steered_by_remb also sends one packet before connecting, but that packet is a VP8 keyframe whose group stays open, so the delay budget never drops it. A 200 ms injected connect delay passes it on main, so it is left as is.

Mocking the clock doesn't fit this test: it runs real HTTP, ICE, and DTLS over loopback sockets, and a paused tokio clock auto-advances through every I/O wait. The meter's own timing is unit-tested with mocked time in rate.rs.

Impact

Test-only. No public API or wire change.

Validation

  • Reproduced deterministically by inserting a 200 ms pause between the pre-connect push and push_whip (past the 100 ms budget): on main the test fails exactly as in CI, the publisher past its cap stayed open: Elapsed after 10.23 s. With this change and the same 200 ms pause, it passes in 0.3 s.
  • The same 200 ms pause in the REMB test passes on main (see Approach).
  • Starved of CPU instead, each run in its own systemd-run -p CPUQuota=10% unit: main failed 15/15 and this branch passed 15/15.
  • Under stress-ng with 48 CPU workers (load average 26.8 on 24 cores), main passed 30/30: plain contention on this host didn't open the window, but starving the test of CPU did.
  • cargo test -p moq-webrtc --lib: 109 passed. just check passes.

Caused by

  • moq-dev/moq#7373 - added the test with one packet sent before the push connects, so the media reaching the meter depended on connect timing (found by queue)

Models

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

🤖 Generated with Claude Code

(Written by Claude Opus 5.5)

Review

Rewritten by quest review after each round.

  • Head: 600d0cb

  • Base: origin/main at 1fd8509

  • Risk: low, The diff changes only test code inside the `mod tests` block of rs/moq-webrtc/src/lib.rs (the WHIP cap test helpers and assertions), so nothing a consumer, peer, or published API relies on can break, and reverting the single file fully undoes it.

  • Classified: low by Claude Code, claude-haiku-5-5, low effort, session b3d85e46-2352-49be-bae1-3b4ab222fd18

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

  • Session: 01a20653-35cf-7743-85dd-55c7d943ac4e, round 1

  • Score: 9/10, Source review found no actionable defects in the test-only change, though tests were not run as instructed.

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

  • Findings: none

…t is closed

The test sent one Opus packet before the WHIP client connected. A client that
connected past the egress's 100 ms delay budget skipped that packet's group, so
nothing ever crossed the cap and the session stayed open. The source now sends
live until the session ends, as the sibling tests' sources do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated
kixelated marked this pull request as ready for review November 23, 2026 02:57
@coderabbitai

coderabbitai Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 13 seconds.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f9b5a1f6-94ee-4386-8dc3-5309d6f3f9be
Commits

Reviewing files that changed from the base of the PR and between 1fd8509 and 600d0cb.

Files selected for processing: 1

  • rs/moq-webrtc/src/lib.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@kixelated
kixelated enabled auto-merge November 23, 2026 02:58

@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. The test now sends live media until the session ends, so the cap trips whenever the client connects. The root cause was one packet sent before the connect, which the 100 ms delay budget could skip.

Reviewed changes

  • Live::until: extracts play's send loop into a generic "send until a future resolves" helper. play is rebuilt on it with the same stale-payload semantics.
  • Cap test: a_whip_publisher_past_its_cap_plus_burst_is_closed now uses Live and waits on live.until(LOUD, session) inside the existing timeout, replacing the single pre-connect packet.

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

@kixelated
kixelated added this pull request to the merge queue Nov 23, 2026
Merged via the queue into main with commit 0192c2d Nov 23, 2026
11 checks passed
@kixelated
kixelated deleted the fix/whip-cap-flaky-test branch November 23, 2026 07:00
kixelated added a commit that referenced this pull request Nov 25, 2026
#9452 already resends the loud frame until the session closes, which
removed the race with the WHIP client's connect. The epic holds no other
child, so it completes here.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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