Skip to content

Backoff Reconnect #6358

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
May 15, 2025
Merged

Backoff Reconnect #6358

merged 23 commits into from
May 15, 2025

Conversation

lee-at-zoo-corp
Copy link
Contributor

@lee-at-zoo-corp lee-at-zoo-corp commented Apr 16, 2025

  • Backoff reconnect behavior added (Fibonacci sequence used due to nice time scaling properties)
  • Translate WebSocket error numbers to text on the loading screen
  • Detect disconnections and reconnect
  • Restore camera state on reconnect even on sudden disconnects
  • Add a RestartRequest event that the application can fire at any point to restart the engineConnection
  • Add E2E stream pause test
  • Lifted more logic from EngineStream into engineStreamMachine
  • Added a slew of debug messages to network code startup

Copy link

vercel bot commented Apr 16, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
modeling-app ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 15, 2025 3:52pm

Copy link

qa-wolf bot commented Apr 16, 2025

QA Wolf here! As you write new code it's important that your test coverage is keeping up.
Click here to request test coverage for this PR!

@lee-at-zoo-corp lee-at-zoo-corp force-pushed the lee-at-zoo-corp/backoff-reconnect branch from 385d799 to dd8b870 Compare April 16, 2025 20:46
Copy link

codecov bot commented Apr 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.41%. Comparing base (3a23ec1) to head (3dc4e0f).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6358   +/-   ##
=======================================
  Coverage   85.41%   85.41%           
=======================================
  Files         109      109           
  Lines       47482    47482           
=======================================
  Hits        40559    40559           
  Misses       6923     6923           
Flag Coverage Δ
rust 85.41% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@pierremtb pierremtb left a comment

Choose a reason for hiding this comment

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

Alright I parsed through it, I can't pretend that I understand it all but it all seems to make sense. I have one request to look at before merging: the use of the TEST env var, see comment at the top of EngineStream.tsx about using an existing helper.

Going to test locally now!

Comment on lines +1600 to +1616
// We should eventually only have 1 restoral call.
if (this.idleMode) {
await this.sceneInfra?.camControls.restoreRemoteCameraStateAndTriggerSync()
} else {
// NOTE: This code is old. It uses the old hack to restore camera.
console.log('call default_camera_get_settings')
// eslint-disable-next-line @typescript-eslint/no-floating-promises
await this.sendSceneCommand({
// CameraControls subscribes to default_camera_get_settings response events
// firing this at connection ensure the camera's are synced initially
type: 'modeling_cmd_req',
cmd_id: uuidv4(),
cmd: {
type: 'default_camera_get_settings',
},
})
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The await keyword is missing in the if (this.idleMode) branch when calling this.sceneInfra?.camControls.restoreRemoteCameraStateAndTriggerSync(). This could lead to timing issues since the function appears to be asynchronous. Both branches should consistently use await to ensure proper sequencing of operations during camera restoration.

// Should be:
if (this.idleMode) {
  await this.sceneInfra?.camControls.restoreRemoteCameraStateAndTriggerSync()
} else {
  // ...
}

Spotted by Diamond

Is this helpful? React 👍 or 👎 to let us know.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wow the first time it's wrong? Both branches clearly use await?

Copy link
Contributor

@pierremtb pierremtb left a comment

Choose a reason for hiding this comment

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

Tested locally on macOS and Windows. LGTM!

And thanks for the changes!

@lee-at-zoo-corp lee-at-zoo-corp merged commit 3f00e71 into main May 15, 2025
49 checks passed
@lee-at-zoo-corp lee-at-zoo-corp deleted the lee-at-zoo-corp/backoff-reconnect branch May 15, 2025 15:58
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.

Improved error when you cant get a stream
4 participants