-
Notifications
You must be signed in to change notification settings - Fork 127
Computed retry delay #664
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
Computed retry delay #664
Conversation
it seems like you haven't added any nanpa changeset files to this PR. if this pull request includes changes to code, make sure to add a changeset, by writing a file to
refer to the manpage for more information. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM ✅
// First two attempts use fixed delay (0ms, 300ms) | ||
return attempt == 0 ? 0 : baseDelay | ||
} else if attempt < 5 { | ||
// Next 3 attempts use exponential backoff with optional jitter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my local testing, it may help with the
More sensible retry delay defaults, adopted from the JS SDK.
This pull request focuses on improving the reconnect delay logic in the LiveKit SDK. The main changes include the introduction of a more sophisticated delay computation method, updates to the reconnect options, and enhancements to logging for better traceability.
Improvements to reconnect delay logic:
.nanpa/improve-reconnect-delay-logic.kdl
: Added a patch to improve reconnect delay logic.Sources/LiveKit/Core/Room+Engine.swift
: Modified the retry mechanism to use a computed reconnect delay with jitter and updated logging to reflect these changes. [1] [2] [3]Sources/LiveKit/Extensions/TimeInterval.swift
: Introduced new constants for reconnect delays and a new methodcomputeReconnectDelay
to calculate delays based on an ease-out curve with optional jitter. [1] [2]Enhancements to reconnect options:
Sources/LiveKit/Types/Options/ConnectOptions+Copy.swift
: AddedreconnectMaxDelay
to thecopyWith
method to allow copying this new option.Sources/LiveKit/Types/Options/ConnectOptions.swift
: UpdatedConnectOptions
to includereconnectMaxDelay
, adjusted the default values, and ensured the maximum delay is respected. [1] [2] [3] [4] [5] [6]Enhancements to retry mechanism:
Sources/LiveKit/Support/AsyncRetry.swift
: Updated the retrying logic to accept a closure for dynamic delay computation and adjusted logging to reflect the computed delays.