This repository was archived by the owner on Apr 24, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -225,19 +225,32 @@ public async Task MakeRequest(Batch batch)
225
225
if ( _client . Config . CompressRequest )
226
226
content . Headers . ContentEncoding . Add ( "gzip" ) ;
227
227
228
- var response = await _httpClient . PostAsync ( uri , content ) . ConfigureAwait ( false ) ;
228
+ HttpResponseMessage response = null ;
229
+ bool retry = false ;
230
+ try
231
+ {
232
+ response = await _httpClient . PostAsync ( uri , content ) . ConfigureAwait ( false ) ;
233
+ }
234
+ catch ( System . Threading . Tasks . TaskCanceledException )
235
+ {
236
+ retry = true ;
237
+ }
238
+ catch ( System . Exception e )
239
+ {
240
+ throw e ;
241
+ }
229
242
230
243
watch . Stop ( ) ;
231
244
232
- if ( response . StatusCode == HttpStatusCode . OK )
245
+ if ( response != null && response . StatusCode == HttpStatusCode . OK )
233
246
{
234
247
Succeed ( batch , watch . ElapsedMilliseconds ) ;
235
248
break ;
236
249
}
237
250
else
238
251
{
239
- statusCode = ( int ) response . StatusCode ;
240
- if ( ( statusCode >= 500 && statusCode <= 600 ) || statusCode == 429 )
252
+ statusCode = response != null ? ( int ) response . StatusCode : 0 ;
253
+ if ( ( statusCode >= 500 && statusCode <= 600 ) || statusCode == 429 || retry )
241
254
{
242
255
// If status code is greater than 500 and less than 600, it indicates server error
243
256
// Error code 429 indicates rate limited.
You can’t perform that action at this time.
0 commit comments