Repository navigation
fix(events): end an ordinary failure's wait on going online again - #447
Open
abelonogov-ld wants to merge 1 commit into
Open
abelonogov-ld wants to merge 1 commit into
abelonogov-ld wants to merge 1 commit into
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
This branch has not been deployed
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.


Follow-up from the iOS tier 3 review (ios-client-sdk#538 thread), matching the iOS change in code and comments.
After a failed post, going offline and online again left the whole wait in place, so events that failed while the network was gone sat out the rest of that wait, or until the next flush interval. The reviewers agreed on a narrow rule, which durability section 9 now states and conformance item C8d pins:
Retry-After): going online again ends its wait and delivers right away. The attempt count stays, so a failure of that post takes the next step of the backoff.Retry-After, or the longer backoff after a refusal such as a 401 or 403): going online again keeps it. Devices come back online together after a regional outage, and ending these waits would bring back the stampedeRetry-Afterexists to prevent.Changes:
DeliveryRetryState.endOrdinaryWait()ends only an ordinary failure's wait. It tracks a refusal since the last accepted delivery, and whether the wait is aRetry-After's, including onerecordFailureDuringWaitlengthened.DirectEventProcessor.setOffline(false)calls it and submits a delivery. If the launch gate is still closed, the delivery is owed to the gate opening, where one delivery covers it and a previous run's events, as on iOS. Without that, ending the wait before the gate opened sent nothing until the next flush interval.LDClientInterface.setOnline()documents both cases, including that a service-set wait holds when a captive portal or proxy answered, and that atDISABLEDpersistence events held during it are lost if the process ends.DeliveryRetryStatedocs describe the two kinds of wait in the same words as iOS.Tests:
DeliveryRetryStateTest: ends an ordinary wait but keeps the count; keeps a refusal's, aRetry-After's and a lengthened wait; lets a delivery go once a service wait ran out; nothing to send after an accepted delivery.DirectEventProcessorTest: posts at once after an ordinary failure; keeps a 401's and aRetry-After's wait; posts as the launch gate opens when going online again before it (this one fails without the owed delivery).All 1285 unit tests pass locally.
Note
Overview
Fixes event delivery after the client goes online again following a failed post: ordinary failures (no network, 5xx without
Retry-After) now clear their backoff wait and trigger delivery immediately, while service-directed waits (Retry-After, 401/403-style refusal backoff) stay in place so reconnecting devices do not stampede the API.DeliveryRetryStategainsendOrdinaryWait()plusrefused/serverDirectedWaittracking so only ordinary waits can be cleared without resetting attempt counts.DirectEventProcessor.setOffline(false)calls it and queuesdeliverPayload; if the launch gate is still closed,deliveryOwedAtGatedefers that delivery until the gate opens (same path as previous-run events). PublicLDClientInterface.setOnline()javadoc documents both behaviors.Unit and integration tests cover retry-state edge cases and processor behavior (immediate post vs. held waits, launch-gate deferral).
Reviewed by Cursor Bugbot for commit 975d916. Bugbot is set up for automated code reviews on this repo. Configure here.