Added handling for when we have network failures in the retry mechanism (#223)
* Added handling for when we have network failures in the retry mechanism * forgot ";' * Fixed to be proper version * .
This commit is contained in:
Родитель
f8d4424872
Коммит
06d0fc1eae
|
@ -41,6 +41,7 @@ export enum HttpCodes {
|
|||
|
||||
const HttpRedirectCodes: number[] = [HttpCodes.MovedPermanently, HttpCodes.ResourceMoved, HttpCodes.SeeOther, HttpCodes.TemporaryRedirect, HttpCodes.PermanentRedirect];
|
||||
const HttpResponseRetryCodes: number[] = [HttpCodes.BadGateway, HttpCodes.ServiceUnavailable, HttpCodes.GatewayTimeout];
|
||||
const NetworkRetryErrors: string[] = ['ECONNRESET', 'ENOTFOUND', 'ESOCKETTIMEDOUT', 'ETIMEDOUT', 'ECONNREFUSED'];
|
||||
const RetryableHttpVerbs: string[] = ['OPTIONS', 'GET', 'DELETE', 'HEAD'];
|
||||
const ExponentialBackoffCeiling = 10;
|
||||
const ExponentialBackoffTimeSlice = 5;
|
||||
|
@ -243,8 +244,15 @@ export class HttpClient implements ifm.IHttpClient {
|
|||
|
||||
let response: HttpClientResponse;
|
||||
while (numTries < maxTries) {
|
||||
response = await this.requestRaw(info, data);
|
||||
|
||||
try{
|
||||
response = await this.requestRaw(info, data);
|
||||
}
|
||||
catch (err) {
|
||||
if(err && err.code && NetworkRetryErrors.indexOf(err.code) > -1){
|
||||
continue;
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
// Check if it's an authentication challenge
|
||||
if (response && response.message && response.message.statusCode === HttpCodes.Unauthorized) {
|
||||
let authenticationHandler: ifm.IRequestHandler;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "typed-rest-client",
|
||||
"version": "1.7.3",
|
||||
"version": "1.8.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "typed-rest-client",
|
||||
"version": "1.7.3",
|
||||
"version": "1.8.0",
|
||||
"description": "Node Rest and Http Clients for use with TypeScript",
|
||||
"main": "./RestClient.js",
|
||||
"scripts": {
|
||||
|
|
Загрузка…
Ссылка в новой задаче