Skip to content

fix(events): end an ordinary failure's wait on going online again - #447

Open
abelonogov-ld wants to merge 1 commit into
mainfrom
andrey/going-online-ends-ordinary-wait
Open

abelonogov-ld wants to merge 1 commit into
mainfrom
andrey/going-online-ends-ordinary-wait

Conversation

@abelonogov-ld

@abelonogov-ld abelonogov-ld commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

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:

  • Ordinary failure (no response, or a 5xx without 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.
  • Wait the service set (a 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 stampede Retry-After exists 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 a Retry-After's, including one recordFailureDuringWait lengthened.
  • 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 at DISABLED persistence events held during it are lost if the process ends.
  • The DeliveryRetryState docs 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, a Retry-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 a Retry-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.

DeliveryRetryState gains endOrdinaryWait() plus refused / serverDirectedWait tracking so only ordinary waits can be cleared without resetting attempt counts. DirectEventProcessor.setOffline(false) calls it and queues deliverPayload; if the launch gate is still closed, deliveryOwedAtGate defers that delivery until the gate opens (same path as previous-run events). Public LDClientInterface.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.

Co-authored-by: Cursor <cursoragent@cursor.com>
@abelonogov-ld
abelonogov-ld requested a review from a team as a code owner November 24, 2026 21:22

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Risk: medium. Not approved: Rule 2 (allowed PR authors) and the low-risk approval threshold both require human review for this event-delivery retry change. Cursor Bugbot passed with no findings; no reviewers were assigned.

Open in Web View Automation 

Sent by Cursor Approval Agent: SDK - Pull Request Router and Approver

This branch has not been deployed

No deployments
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.

1 participant