feat(audience): exponential backoff, 429/Retry-After, HTTP timeout, 4xx drop (SDK-291)#2873
Merged
Conversation
…xx drop (SDK-291) - Exponential backoff in MessageQueue: 5s → 10s → 20s → 40s → 60s cap - 429 handling: parse Retry-After header, override backoff with server delay, emit RATE_LIMITED - 30s AbortController timeout on fetch; timeouts surface as NETWORK_ERROR - 4xx (non-429) treated as terminal: drop batch, emit VALIDATION_REJECTED Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
View your CI Pipeline Execution ↗ for commit a75a24c
☁️ Nx Cloud last updated this comment at |
|
View your CI Pipeline Execution ↗ for commit a75a24c
☁️ Nx Cloud last updated this comment at |
✅ Pixel Bundle Size — @imtbl/pixel
Budget: 10.00 KB gzipped (warn at 8.00 KB) |
✅ Audience Bundle Size — @imtbl/audience
Budget: 24.00 KB gzipped (warn at 20.00 KB) |
ImmutableJeffrey
approved these changes
May 20, 2026
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.
Fixes four gaps in
@imtbl/audience-corevs Unity SDK:Retry-Afterheader; queue uses server-supplied delay and emits a newRATE_LIMITEDerror codeAbortControllertimeout on everyfetch; hung connections surface asNETWORK_ERRORinstead of wedging the queueVALIDATION_REJECTEDemitted) instead of retrying foreverNote
Medium Risk
Changes message flushing and transport behavior (timeouts, retry windows, and terminal vs retryable HTTP statuses), which can affect event delivery timing and drop conditions if misclassified. Covered by new unit tests, but it alters core queue/transport control flow.
Overview
Adds queue-level exponential backoff to
MessageQueue.flush()so repeated send failures suppress further flush attempts until a growing delay window elapses, and resets the backoff after a successful or terminally-rejected batch.Extends the transport/SDK error surface to handle HTTP 429 rate limits:
TransportResultcan now includeretryAfterMs,httpSendparsesRetry-After, and a newAudienceErrorCodeRATE_LIMITEDis emitted while keeping the batch queued and delaying retries.Introduces a 30s fetch timeout via
AbortController(surfacing asstatus: 0network errors) and treats non-429 4xx during flush as terminal by mapping them toVALIDATION_REJECTEDand dropping the batch. Unit tests were added/updated to cover backoff escalation,Retry-After, timeout behavior, and 4xx drop semantics.Reviewed by Cursor Bugbot for commit a75a24c. Bugbot is set up for automated code reviews on this repo. Configure here.