-
Notifications
You must be signed in to change notification settings - Fork 1
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
Introduce a wait to work around history not being “live” #176
Conversation
WalkthroughThe changes in this pull request focus on modifying the Changes
Assessment against linked issues
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
Tests/AblyChatTests/IntegrationTests.swift (1)
120-138
: Consider adding timeout information to the documentationThe comment effectively explains the issue and workaround. However, since this is a retry mechanism, it would be helpful to document:
- Whether there should be a maximum number of retries
- What timeout scenarios should be considered
- What behavior is expected if history remains consistently empty
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
Tests/AblyChatTests/IntegrationTests.swift
(1 hunks)
🔇 Additional comments (1)
Tests/AblyChatTests/IntegrationTests.swift (1)
139-148
: Consider adding timeout and exponential backoff
While the current implementation works around the history system limitation, it could be more robust with:
- A maximum retry limit or timeout to prevent infinite loops
- Exponential backoff instead of fixed delay
- Error handling for timeout scenarios
Here's a suggested implementation:
let rxMessagesBeforeSubscribing = try await {
+ let maxAttempts = 5
+ var attempt = 0
while true {
+ attempt += 1
let messages = try await rxMessageSubscription.getPreviousMessages(params: .init())
if !messages.items.isEmpty {
return messages
}
+ guard attempt < maxAttempts else {
+ throw NSError(domain: "IntegrationTests",
+ code: 1,
+ userInfo: [NSLocalizedDescriptionKey: "Timeout waiting for history"])
+ }
- try await Task.sleep(nanoseconds: NSEC_PER_SEC)
+ // Exponential backoff: 1s, 2s, 4s, 8s, 16s
+ try await Task.sleep(nanoseconds: UInt64(pow(2.0, Double(attempt - 1))) * NSEC_PER_SEC)
}
}()
Let's verify if similar retry patterns exist elsewhere in the codebase:
Replaced by #177. |
(The integration tests are still failing, though, due to #169, but at least they’re now failing in a consistent manner.)
Resolves #167.
Summary by CodeRabbit
Bug Fixes
Documentation