Repository navigation
Conversation
A DNS failure, a refused or reset connection, or a TLS error, such as behind a captive portal, made `processUnknownError` drop the batch with no retry. These errors mean the request may never have reached Amplitude, so they are now retried like a timeout, with the same backoff and `FlushMaxRetries` limit. An event that did arrive is deduplicated by its `insert_id`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UrTUMwAzz2CXk6SjcnYYu1
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.
Summary
A failed send is retried only when the error is a timeout, a 408 or a 5xx. Any other transport error goes to
processUnknownError, which hands the batch to the callback and drops it. These include a DNS failure, a refused or reset connection, and a TLS error, such as behind a captive portal or a TLS-intercepting proxy. A client that is briefly offline, or online behind a captive portal, loses every event it tries to send.This PR retries any
*url.Errorfromhttp.Client.Dolike a timeout, with the same backoff and the sameFlushMaxRetrieslimit. The request may never have reached Amplitude. If it did, the retry is deduplicated by theinsert_idthatContextPluginsets on every event.Errors that aren't
*url.Errorkeep their current handling. These are a payload that can't be encoded, a request that can't be built, and a response body that can't be read after a 200.TestNetworkErrorcovers a DNS failure, a refused connection and a TLS certificate error, wrapped the wayamplitudeHTTPClient.Sendwraps them. It fails without the change.go test -race ./amplitude/...andgo vet ./amplitude/...pass.Found in DDEV, which sends a weekly count of each command it runs (ddev/ddev#9071). Losing one batch there loses a week of counts.
Checklist
FlushMaxRetries, and reachExecuteCallbackonly after the last retry.🤖 Generated with Claude Code
https://claude.ai/code/session_01UrTUMwAzz2CXk6SjcnYYu1
Note
Low Risk
Narrows failure handling to retry transient network issues; behavior for non-url errors is unchanged and duplicates are mitigated by insert_id deduplication.
Overview
Retries any HTTP transport failure instead of only timeouts, 408, and 5xx. Batches that hit a
*url.Errorfromhttp.Client.Do(DNS failure, connection refused/reset, TLS errors) now follow the same path as timeouts: exponential backoff,FlushMaxRetries, and callback only after the last attempt. Commentary notes Amplitude deduplicates viainsert_idif a request actually succeeded.Adds
TestNetworkErrorfor DNS, connection refused, and captive-portal-style TLS errors, using the same wrapped error shape asamplitudeHTTPClient.Send.Reviewed by Cursor Bugbot for commit cd13f8b. Bugbot is set up for automated code reviews on this repo. Configure here.