fix: stream auto-reconnect and preserve scene entities during disconnect#823
fix: stream auto-reconnect and preserve scene entities during disconnect#823Devin T. Currie (DTCurrie) wants to merge 8 commits into
Conversation
- Add retryStream utility with exponential backoff (1s–30s) - Wrap streamEntityChanges and streamSceneChanges in useDrawService with retryStream so the draw backend reconnects automatically after errors - Guard entity cleanup in useGeometries and usePointclouds: when all queries disappear (transient disconnect), preserve existing ECS entities so the scene doesn't go blank; only destroy entities when the partID changes or other queries remain active Co-authored-by: Devin T. Currie <DTCurrie@users.noreply.github.com>
🦋 Changeset detectedLatest commit: 4e925fb The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
|
Claude (@claude) adversarial review |
|
Claude finished Devin T. Currie (@DTCurrie)'s task in 4m 32s —— View job Adversarial Review
SummaryThe CriticalStale entity maps after reconnect (comment) High
MediumNo
Low / NitsPreserve-logic condition (comment) — logic is correct but non-obvious; a one-line comment on the Missing test cases (comment 1, comment 2) — No jitter — pure exponential backoff risks thundering-herd if multiple clients reconnect simultaneously after a server restart. Low risk for the current single-robot use case but worth noting. No tests for the useGeometries/usePointclouds preserve logic — the ECS preservation behavior is the most user-visible part of this PR and has zero unit test coverage. |
|
|
||
| await promise | ||
|
|
||
| expect(run).toHaveBeenCalledTimes(3) |
There was a problem hiding this comment.
Missing test: delay cap at MAX_DELAY_MS (30 s) is untested.
The exponential doubling is exercised up to 2 s but never hits the 30 s ceiling. Worth one parameterized test that runs enough failures to saturate the cap and verifies onRetry stops receiving larger values.
Also missing: a test for what happens when signal is already aborted before retryStream is called (the while (!signal.aborted) check on the first iteration). The current suite only aborts during an in-flight operation or backoff.
There was a problem hiding this comment.
Claude finished Devin T. Currie (@DTCurrie)'s task in 4m 12s —— View job
- Read CLAUDE.md and test file context
- Read retry-stream implementation
- Add test for MAX_DELAY_MS cap (30s ceiling)
- Add test for pre-aborted signal
- Commit and push
Both missing tests have been added in commit 4e925fb:
caps delay at MAX_DELAY_MS (30s) and does not double beyond it — runs 6 consecutive failures to drive the backoff through 1s → 2s → 4s → 8s → 16s → 30s (capped), then asserts the 6th onRetry call received 30_000 rather than 32_000.
does not call run when signal is already aborted before retryStream is called — pre-aborts the controller before passing the signal, asserts run is never invoked (tests the while (!signal.aborted) guard on first entry).
· Branch
|
Claude finished Micheal Parks (@micheal-parks)'s task in 3m 3s —— View job Analysis:
|
Claude (@claude) lets make these changes. I think we go with option 2 for now. |
|
Claude finished Devin T. Currie (@DTCurrie)'s task in 2s —— View job Implementing
|
…ep leak - Bump @viamrobotics/svelte-sdk to 1.2.3 and set resetQueriesOnDisconnect:false in ViamProvider so query data persists across disconnects in the dev app; hook-level preserve logic remains as a safe fallback for library consumers - Clear transformEntities/drawingEntities and destroy ECS entities in the onRetry callback so the server's ADDED re-bootstrap after reconnect can rebuild from scratch (fixes silent entity drop on stale map entries) - Set connectionStatus = CONNECTING in onRetry so the UI shows reconnect is in progress rather than staying DISCONNECTED indefinitely - Add onRetry warn log to streamSceneChanges so scene-stream failures are no longer silently swallowed - Fix sleep() memory leak: remove the abort listener when the timer fires normally so it doesn't accumulate dangling listeners during long outages Co-authored-by: Devin T. Currie <DTCurrie@users.noreply.github.com>
|
Claude (@claude) resolve or hide outdated comments |
|
Claude finished Devin T. Currie (@DTCurrie)'s task in 2m 11s —— View job Resolved outdated review comments
Resolved (6 threads):
Still open (2 threads):
|
|
Hey Devin T. Currie (@DTCurrie) — this PR has been approved and CI has been green for 4+ business days. Ready to merge? Auto-comment from overwatch. Will not re-nudge for 7 days. |
|
Claude finished Devin T. Currie (@DTCurrie)'s task in 1m 53s —— View job
DoneRenamed The new name accurately reflects what the test asserts: |
Rename 'stops retrying when signal is aborted' to accurately reflect that onRetry IS called once (signaling intent to retry) before the backoff sleep, but run is not called again because the abort fires during the backoff window. Co-authored-by: Devin T. Currie <DTCurrie@users.noreply.github.com>
|
Claude finished Devin T. Currie (@DTCurrie)'s task in 1m 58s —— View job
DoneAdded two tests to
|
Co-authored-by: Devin T. Currie <DTCurrie@users.noreply.github.com>
Closes #584
(authored by claude)