feat(e2e-cli): add flush-retry loop to simulate real flush policy#1173
Merged
abueide merged 9 commits intotapi/types-and-errorsfrom Mar 19, 2026
Merged
feat(e2e-cli): add flush-retry loop to simulate real flush policy#1173abueide merged 9 commits intotapi/types-and-errorsfrom
abueide merged 9 commits intotapi/types-and-errorsfrom
Conversation
The CLI previously called flush() once and exited, so events that received retryable errors (5xx, 429) stayed in the queue with no retry. This implements the retry loop that flush policies drive in a real app: flush → check pending → wait for backoff → repeat. - Flush-retry loop respects maxRetries from test config - Forward-compatible with tapi RetryManager (reads backoff state when available, falls back to fixed delay on master) - Tracks permanently dropped events via logger interception - Reports success=false when events remain or are dropped - Computes sentBatches from delivered event count - Enables retry test suite in e2e-config.json Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Instead of manually calling flush() in a loop and reading private RetryManager state, let the SDK's built-in flush policies drive retries. TimerFlushPolicy fires every flushInterval (100ms default for e2e), and the RetryManager gates actual uploads during backoff. The CLI just triggers the initial flush, then polls pendingEvents() until the queue drains or 30s timeout. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Pass maxRetries from test config into httpConfig overrides so the SDK enforces retry limits during e2e tests - Set output.error when permanentDropCount > 0 so failure reporting tests get a truthy error field - Add BROWSER_BATCHING=true to e2e-config.json to skip tests that assume ephemeral per-request batching (RN uses persistent queue re-chunking) - Add jsx: react to tsconfig.json for .tsx transitive imports Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Extract buildConfig, dispatchEvent, waitForQueueDrain, and interceptDropCount from main(). Drop redundant per-event validation warnings and error handling. 367 -> 256 lines. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Return boolean from waitForQueueDrain to indicate drain vs timeout - Add JSDoc for interceptDropCount noting coupling to SegmentDestination log format - Add console.warn in dispatchEvent when events are skipped for missing fields - Add comment on sentBatches approximation Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace fragile log-interception pattern in e2e-cli with a proper counter on SegmentDestination. The CLI now calls client.droppedEvents() instead of monkey-patching logger.error and regex-matching drop messages. - Add droppedEventCount property to SegmentDestination - Add droppedEvents() accessor on SegmentClient (mirrors pendingEvents) - Remove interceptDropCount helper from e2e-cli Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ff837e7 to
a3ac0e5
Compare
623ad53 to
ec82caa
Compare
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.
Summary
flush()+ 500ms wait with a proper flush-retry loop that simulates the flush policy cadence a real app usesTimerFlushPolicy(100ms interval), then pollspendingEvents()until the queue drains or timeoutsuccess(false when events remain in queue or were permanently dropped) andsentBatches(derived from delivered event count)logger.error()messages emitted by SegmentDestination when events are permanently dropped or retry-limit-exceededretrytest suite ine2e-config.jsonDepends on #1156 (tapi/types-and-errors) for
httpConfigonConfig.Context
The SDK uses a deferred retry model: failed events stay in a persistent queue and are retried on the next flush policy trigger (timer every 30s, count threshold at 20). The CLI had no flush policies running — it called
flush()once and exited. Events that received retryable errors (5xx, 429) were left in the queue with no retry, causing ~20 retry e2e tests to fail.What this fixes
successfield reporting (was hardcoded totrue)sentBatchestracking (was hardcoded to0)maxRetrieswiring tohttpConfig.rateLimitConfigandhttpConfig.backoffConfigTest plan
esbuildbuild succeeds{"success":true,"sentBatches":0}🤖 Generated with Claude Code