You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
returnfmt.Errorf("failed to read request body: %v", err)
161
161
}
162
162
}
163
163
164
-
retryLoop:
165
164
fori:=0; i<=options.Retries; i++ {
166
165
167
166
// Reset body to the original request body
@@ -189,21 +188,24 @@ retryLoop:
189
188
190
189
// exit on non-retriable status codes
191
190
if!options.canRetry(resp.StatusCode) {
192
-
failures=append(failures, fmt.Sprintf("exiting due to non-retriable error in try #%d/%d: %v", i+1, options.Retries+1, resp.StatusCode))
193
-
returnfmt.Errorf("request failed on non-retriable error: %v", strings.Join(failures, "; "))
191
+
failures=append(failures, fmt.Sprintf("exiting due to non-retriable error in try #%d/%d: %d %s", i+1, options.Retries+1, resp.StatusCode, resp.Status))
192
+
slog.Error("sendRequest failed due to non-retriable statuscode", "code", resp.StatusCode, "status", resp.Status, "tries", i+1, "maxTries", options.Retries+1, "failures", strings.Join(failures, "; "))
193
+
returnfmt.Errorf("request failed on non-retriable status-code: %d %s", resp.StatusCode, resp.Status)
returnnil, fmt.Errorf("failed to read request body: %v", err)
233
234
}
234
235
}
235
236
236
-
streamRetryLoop:
237
237
fori:=0; i<=options.Retries; i++ {
238
238
239
239
// Reset body to the original request body
@@ -263,8 +263,9 @@ streamRetryLoop:
263
263
264
264
// exit on non-retriable status codes
265
265
if!options.canRetry(resp.StatusCode) {
266
-
failures=append(failures, fmt.Sprintf("exiting due to non-retriable error in try #%d/%d: %v", i+1, options.Retries+1, resp.StatusCode))
267
-
returnnil, fmt.Errorf("request failed on non-retriable error: %v", strings.Join(failures, "; "))
266
+
failures=append(failures, fmt.Sprintf("exiting due to non-retriable error in try #%d/%d: %d %s", i+1, options.Retries+1, resp.StatusCode, resp.Status))
267
+
slog.Error("sendRequestStream failed due to non-retriable statuscode", "code", resp.StatusCode, "status", resp.Status, "tries", i+1, "maxTries", options.Retries+1, "failures", strings.Join(failures, "; "))
268
+
returnnil, fmt.Errorf("request failed on non-retriable status-code: %d %s", resp.StatusCode, resp.Status)
268
269
}
269
270
270
271
// exponential backoff
@@ -273,11 +274,14 @@ streamRetryLoop:
273
274
select {
274
275
case<-req.Context().Done():
275
276
failures=append(failures, fmt.Sprintf("exiting due to canceled context after try #%d/%d: %v", i+1, options.Retries+1, req.Context().Err()))
276
-
break streamRetryLoop
277
+
slog.Error("sendRequestStream failed due to canceled context", "tries", i+1, "maxTries", options.Retries+1, "failures", strings.Join(failures, "; "))
278
+
returnnil, fmt.Errorf("request failed due to canceled context: %v", req.Context().Err())
0 commit comments