amplitude / amplitude/Amplitude-TypeScript

Browser SDK retries all HTTP errors including not retryable ones

Đang mở
#1,630 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
bug
Ngôn ngữ chính
TypeScript
Star
180
Fork
68
Merge trung bình
3 ngày 1 giờ
Pull request đã merge (30 ngày)
29

Mô tả

## Expected Behavior
According to the documentation, `flushMaxRetries` is described as: "Sets the maximum number of retries for failed upload attempts. **This is only applicable to errors that the SDK can retry.**"

Based on this documentation and standard HTTP retry best practices, the SDK should:
- **Retry** on transient/retryable errors
- **NOT retry** on permanent/client errors

When a non-retryable error (like 501) is returned, the SDK should fail immediately without exhausting retry attempts.

## Current Behavior
The SDK makes up to `flushMaxRetries` attempts even for errors that indicate permanent failures (such as 400 or 501) and will never succeed on retry.

Image

## Possible Solution
Update the retry logic to only retry truly transient errors.

## Steps to Reproduce
1. Configure Amplitude Browser SDK 2 with a custom serverUrl.
2. Set up the endpoint to return a non-retryable HTTP status code (e.g., 501).
3. Track an event.
4. Observe network requests in browser - you will see 5 retry attempts to the endpoint, all returning 501, even though this is a permanent error that will never succeed.

## Environment
- JS SDK Version: `analytics-browser@2.36.1`
- Installation Method: NPM
- Browser and Version: Chrome 145.0.7632.159

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.