fix(flags): retry DNS, TLS, and connection-refused failures on /flags - #828
Draft
posthog[bot] wants to merge 1 commit into
Draft
posthog[bot] wants to merge 1 commit into
posthog[bot] wants to merge 1 commit into
Conversation
The http-client spec requires flag evaluation requests to retry when the request failed with a transient transport condition, naming DNS, socket, and TLS transport failures explicitly. `isRetryableFlagsError` only covered timeouts, EOF, and `SocketException`s whose message contains "reset", so `UnknownHostException`, `SSLException`, and `ConnectException` fell through unretried. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Generated-By: PostHog Desktop Task-Id: 63bc8676-4e47-42d8-8b84-0bf1fdb94a03
Contributor
posthog-android Compliance ReportDate: 2026-10-01 06:17:57 UTC ✅ All Tests Passed!46/46 tests passed Capture Tests✅ 29/29 tests passed View Details
Feature_Flags Tests✅ 17/17 tests passed View Details
|
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.
💡 Motivation and Context
Contract:
http-client— "Feature flag evaluation retry policy" (spec).The spec says a flag evaluation request SHALL retry when execution failed with a transient transport condition, "such as a network error, connection reset/lost, timeout, DNS/socket/TLS transport failure, or equivalent platform error".
isRetryableFlagsErrorinPostHogApionly classifiedSocketTimeoutException,EOFException, andSocketExceptions whose message contains "reset" as retryable.UnknownHostException(DNS),SSLException/SSLHandshakeException(TLS), andConnectException(connection refused) fell through and were never retried — common conditions on mobile networks, where a flag reload then silently falls back to cached/default values for the rest of the session.The cross-SDK compliance matrix tracks this as a Partial for this SDK:
Why this is backwards-compatible: no public API, config, or default changes. The retry budget is unchanged (
featureFlagRequestMaxRetries, default one retry;0still disables retries entirely) and the backoff schedule is unchanged. The only behavior difference is that three already-failing cases now get the same bounded retry every other transient transport failure already got. Serialization/programming errors and non-502/504 HTTP statuses are still not retried, as the spec requires.Scope: the classifier lives in the shared
posthogcore module, so the fix applies to bothposthog-androidandposthog-server. Nothing else in the matrix was touched.💚 How did you test it?
IOExceptionstill does not (1 attempt)../gradlew :posthog:test --tests "com.posthog.internal.PostHogApiTest"— pass, new cases confirmed present in the report.make testJava(full core JVM suite) — pass../gradlew :posthog-server:test— pass.make checkFormat— pass.Follow-up (not in this PR): other
SocketExceptionsubclasses (NoRouteToHostException,PortUnreachableException) are still unretried; the explicit-type list was kept narrow deliberately so response-parseIOExceptions stay non-retryable. Worth revisiting if the spec's "equivalent platform error" language is tightened.📝 Checklist
If releasing new changes
pnpm changesetto generate a changeset fileCreated with PostHog Desktop
🤖 Generated with Claude Code