Repository navigation
RSDK-14783 components/camera: flaky test fix TestWhyMustTimeoutOnReadRTP subscription torn down by remote shutdown ordering - #6663
Merged
Conversation
…ot in RTP passthrough tests
TestWhyMustTimeoutOnReadRTP and TestGrandRemoteRebooting shut the grand remote
(remote-2) down by closing its robot first and its web service second. In that
window the web service keeps answering for an already dismantled robot, so a
refresh from remote-1 returns an empty resource list. remote-1 reads that as
"the camera was removed" instead of "the machine went offline": it closes its
camera client, drops the resource from its graph, and stops advertising it to
main. main then closes its own camera client, which terminates the subscription
both tests assert stays alive ("Expected: nil / Actual: 'context canceled'").
Closing the web service first matches how a real viam-server shuts down
(localRobot.Close stops web before tearing down resources) and leaves the parent
with a clean disconnect, which only marks the remote's resources unreachable.
Contributor
Review RequiredThis PR was opened by Claude and requires a minimum of 1 approving reviews before it can be merged. Review process:
Current status: 0/1 approvals. |
10zingpd
requested review from
a team and
Cheuk (cheukt)
and removed request for
a team and
Evan Dorsky (EvanDorsky)
October 16, 2026 19:23
Member
|
Claude (@claude) remove or shorten the comments |
|
Claude finished Cheuk (@cheukt)'s task in 1m 10s —— View job Removing/shortening comments
Condensed both multi-line comments to single one-liners:
|
Co-authored-by: Cheuk <cheukt@users.noreply.github.com>
Cheuk (cheukt)
approved these changes
Oct 16, 2026
Benjamin Rewis (benjirewis)
approved these changes
Oct 16, 2026
Benjamin Rewis (benjirewis)
left a comment
Member
There was a problem hiding this comment.
Seems fair.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
TestWhyMustTimeoutOnReadRTPintermittently fails on CI at client_test.go:1062:The assertion checks that main's RTP subscription survives the grand remote (remote-2) going offline.
Root cause
Both tests shut remote-2 down with:
setupRealRobotstarts a web service that is separate from the robot's own, so between those twocalls a live web server answers requests on behalf of an already dismantled robot — it advertises an
empty resource list. (A real viam-server never exposes this window:
localRobot.ClosecallswebSvc.Stop()before closing resources.)If remote-1's robot client refresh lands in that window, it sees the camera as removed rather than
the machine as offline, so instead of the intended
markRemoteUnreachablepath it:updateResourceClients→unsubscribeAll),remote-2:rtpPassthroughCamerafrom its resource graph, so it stops advertising it,unsubscribeAll→ the test'ssub.Terminatedis canceled withcontext canceled.The window is ~200 ms against a 10 s client refresh interval, hence the rare, timing-dependent
failure (more likely on loaded CI runners).
Reproduction
Temporarily shrinking
configTickerIntervaland the robot client refresh/check intervals to 300 msmakes the failure deterministic:
TestWhyMustTimeoutOnReadRTPandTestGrandRemoteRebootingfail100% of the time on
main, with logs showing exactly the chain above(
Removing resource from remote client→unsubscribeAll terminating sub). With this change bothpass 100% of the time under the same accelerated timers, and they keep passing with the real timers
(verified repeatedly, including under
-racealongside the other remote/passthrough tests in thepackage).
Fix
Close the web service before the robot, matching real viam-server shutdown ordering (and the order
these tests already use in their deferred cleanup). The parent then observes a clean disconnect,
which only marks the remote's resources unreachable and leaves main's subscription intact.
TestGrandRemoteRebootinghas the identical shutdown sequence and the same latent flake (it assertsthe same thing plus continued liveness across remote-2's reboot), so it gets the same fix.
Key: RSDK-14783
Co-authored by Claude agent for Jira.