@springworks/api-client
Advanced tools
Comparing version 3005.332.0 to 3005.333.0
@@ -14,5 +14,5 @@ import { HTTPStatus } from '@springworks/http-status'; | ||
sendRequest<T = any>(req_opts: ApiClientRequestOptions, expected_status_codes: HTTPStatus[], retries?: number): Promise<T>; | ||
sendRequestActual<T = any>(req_opts: ApiClientRequestOptions, expected_status_codes: HTTPStatus[]): Promise<T>; | ||
sendRequestActual<T = any>(req_opts: ApiClientRequestOptions, expected_status_codes: HTTPStatus[], ignore_timeout_error?: boolean): Promise<T>; | ||
sendRequestWithFullResponse<Body = any, Code extends HTTPStatus = number>(req_opts: ApiClientRequestOptions, expected_status_codes: HTTPStatus[]): Promise<BodyWithFullResponse<Body, Code>>; | ||
} | ||
//# sourceMappingURL=api-client.d.ts.map |
@@ -24,3 +24,3 @@ "use strict"; | ||
try { | ||
return await this.sendRequestActual(req_opts, expected_status_codes); | ||
return await this.sendRequestActual(req_opts, expected_status_codes, req_opts.should_log_request_timeout_once && retries !== req_opts.retries); | ||
} | ||
@@ -38,3 +38,3 @@ catch (error) { | ||
} | ||
async sendRequestActual(req_opts, expected_status_codes) { | ||
async sendRequestActual(req_opts, expected_status_codes, ignore_timeout_error = false) { | ||
return new Promise((resolve, reject) => { | ||
@@ -89,8 +89,11 @@ const validated_expected_status_codes = validateExpectedStatusCodes(expected_status_codes); | ||
}); | ||
this.logger.error({ | ||
error: request_error, | ||
original_error: error, | ||
req_opts: loggableRequestOptions(req_opts), | ||
expected_status_codes, | ||
}, 'Error sending request'); | ||
const should_log_error = !is_timeout || !ignore_timeout_error; | ||
if (should_log_error) { | ||
this.logger.error({ | ||
error: request_error, | ||
original_error: error, | ||
req_opts: loggableRequestOptions(req_opts), | ||
expected_status_codes, | ||
}, 'Error sending request'); | ||
} | ||
failure(); | ||
@@ -97,0 +100,0 @@ return reject(request_error); |
@@ -136,5 +136,10 @@ /// <reference types="node" /> | ||
* If added, we retry the request if we get timeouts. At the most, we _should_ never do this more than once (?) | ||
* @default 0 | ||
*/ | ||
retries?: number; | ||
/** | ||
* If "retries" is set and this value is set to `true`, the "Request Time-out" error will only log ONCE per request, | ||
* not once per retry. | ||
* This is useful when the request constantly fails (read troutlet) | ||
*/ | ||
should_log_request_timeout_once?: boolean; | ||
} | ||
@@ -141,0 +146,0 @@ export interface BodyWithFullResponse<Body = any, Code extends HTTPStatus = HTTPStatus> { |
{ | ||
"name": "@springworks/api-client", | ||
"version": "3005.332.0", | ||
"version": "3005.333.0", | ||
"description": "Module for sending requests to other APIs through a circuit breaker", | ||
@@ -32,3 +32,3 @@ "main": "build/main.js", | ||
}, | ||
"gitHead": "87e78def17b05027fe32d855184bad8ff90b867f" | ||
"gitHead": "a6ffeb5810072c32824d0c6a169c9e2a49e239d0" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
82742
670