Skip to content

Commit becb776

Browse files
feat(api): Change the default max retries from 5 to 2
BREAKING CHANGE: The default max retries for api calls has changed from 5 to 2. This may result in more frequent non-200 responses.
1 parent 8ea91ca commit becb776

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 41
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-f53d9282224f2c3943d83d014d64ba61271f3aedef59197cc4dae0102d2b365d.yml
33
openapi_spec_hash: a884fe7d04e9f64675e3943a962ebb65
4-
config_hash: 74799f281947721570d77d51e09f278e
4+
config_hash: 3c3a676f96a972da95e0e85618e64c76

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ together.FileUploadParams{
399399

400400
### Retries
401401

402-
Certain errors will be automatically retried 5 times by default, with a short exponential backoff.
402+
Certain errors will be automatically retried 2 times by default, with a short exponential backoff.
403403
We retry by default all connection errors, 408 Request Timeout, 409 Conflict, 429 Rate Limit,
404404
and >=500 Internal errors.
405405

client_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,11 @@ func TestRetryAfter(t *testing.T) {
8989
}
9090

9191
attempts := len(retryCountHeaders)
92-
if attempts != 6 {
93-
t.Errorf("Expected %d attempts, got %d", 6, attempts)
92+
if attempts != 3 {
93+
t.Errorf("Expected %d attempts, got %d", 3, attempts)
9494
}
9595

96-
expectedRetryCountHeaders := []string{"0", "1", "2", "3", "4", "5"}
96+
expectedRetryCountHeaders := []string{"0", "1", "2"}
9797
if !reflect.DeepEqual(retryCountHeaders, expectedRetryCountHeaders) {
9898
t.Errorf("Expected %v retry count headers, got %v", expectedRetryCountHeaders, retryCountHeaders)
9999
}
@@ -133,7 +133,7 @@ func TestDeleteRetryCountHeader(t *testing.T) {
133133
t.Error("Expected there to be a cancel error")
134134
}
135135

136-
expectedRetryCountHeaders := []string{"", "", "", "", "", ""}
136+
expectedRetryCountHeaders := []string{"", "", ""}
137137
if !reflect.DeepEqual(retryCountHeaders, expectedRetryCountHeaders) {
138138
t.Errorf("Expected %v retry count headers, got %v", expectedRetryCountHeaders, retryCountHeaders)
139139
}
@@ -173,7 +173,7 @@ func TestOverwriteRetryCountHeader(t *testing.T) {
173173
t.Error("Expected there to be a cancel error")
174174
}
175175

176-
expectedRetryCountHeaders := []string{"42", "42", "42", "42", "42", "42"}
176+
expectedRetryCountHeaders := []string{"42", "42", "42"}
177177
if !reflect.DeepEqual(retryCountHeaders, expectedRetryCountHeaders) {
178178
t.Errorf("Expected %v retry count headers, got %v", expectedRetryCountHeaders, retryCountHeaders)
179179
}
@@ -211,7 +211,7 @@ func TestRetryAfterMs(t *testing.T) {
211211
if err == nil {
212212
t.Error("Expected there to be a cancel error")
213213
}
214-
if want := 6; attempts != want {
214+
if want := 3; attempts != want {
215215
t.Errorf("Expected %d attempts, got %d", want, attempts)
216216
}
217217
}

internal/requestconfig/requestconfig.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ func NewRequestConfig(ctx context.Context, method string, u string, body any, ds
164164
req.Header.Add(k, v)
165165
}
166166
cfg := RequestConfig{
167-
MaxRetries: 5,
167+
MaxRetries: 2,
168168
Context: ctx,
169169
Request: req,
170170
HTTPClient: http.DefaultClient,

0 commit comments

Comments
 (0)