|
@@ -215,30 +215,24 @@ export class HttpServiceProxy implements ServiceProxyInterface {
|
|
}
|
|
}
|
|
|
|
|
|
if (retryAttempt) {
|
|
if (retryAttempt) {
|
|
- this.logger.info(
|
|
|
|
|
|
+ this.logger.debug(
|
|
`Request to ${serverUrl}/${endpointOrMethodIdentifier} succeeded after ${retryAttempt} retries`,
|
|
`Request to ${serverUrl}/${endpointOrMethodIdentifier} succeeded after ${retryAttempt} retries`,
|
|
)
|
|
)
|
|
}
|
|
}
|
|
|
|
|
|
return serviceResponse
|
|
return serviceResponse
|
|
} catch (error) {
|
|
} catch (error) {
|
|
- const errorMessage = (error as AxiosError).isAxiosError
|
|
|
|
- ? JSON.stringify((error as AxiosError).response?.data)
|
|
|
|
- : (error as Error).message
|
|
|
|
-
|
|
|
|
- this.logger.error(
|
|
|
|
- `Could not pass the request to ${serverUrl}/${endpointOrMethodIdentifier} on underlying service: ${JSON.stringify(
|
|
|
|
- error,
|
|
|
|
- )}`,
|
|
|
|
- )
|
|
|
|
-
|
|
|
|
const requestTimedOut =
|
|
const requestTimedOut =
|
|
'code' in (error as Record<string, unknown>) && (error as Record<string, unknown>).code === 'ETIMEDOUT'
|
|
'code' in (error as Record<string, unknown>) && (error as Record<string, unknown>).code === 'ETIMEDOUT'
|
|
const tooManyRetryAttempts = retryAttempt && retryAttempt > 2
|
|
const tooManyRetryAttempts = retryAttempt && retryAttempt > 2
|
|
if (!tooManyRetryAttempts && requestTimedOut) {
|
|
if (!tooManyRetryAttempts && requestTimedOut) {
|
|
await this.timer.sleep(50)
|
|
await this.timer.sleep(50)
|
|
|
|
|
|
- this.logger.info(`Retrying request to ${serverUrl}/${endpointOrMethodIdentifier} for the ${retryAttempt} time`)
|
|
|
|
|
|
+ const nextRetryAttempt = retryAttempt ? retryAttempt + 1 : 1
|
|
|
|
+
|
|
|
|
+ this.logger.debug(
|
|
|
|
+ `Retrying request to ${serverUrl}/${endpointOrMethodIdentifier} for the ${nextRetryAttempt} time`,
|
|
|
|
+ )
|
|
|
|
|
|
return this.getServerResponse(
|
|
return this.getServerResponse(
|
|
serverUrl,
|
|
serverUrl,
|
|
@@ -246,10 +240,20 @@ export class HttpServiceProxy implements ServiceProxyInterface {
|
|
response,
|
|
response,
|
|
endpointOrMethodIdentifier,
|
|
endpointOrMethodIdentifier,
|
|
payload,
|
|
payload,
|
|
- retryAttempt ? retryAttempt + 1 : 1,
|
|
|
|
|
|
+ nextRetryAttempt,
|
|
)
|
|
)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ const errorMessage = (error as AxiosError).isAxiosError
|
|
|
|
+ ? JSON.stringify((error as AxiosError).response?.data)
|
|
|
|
+ : (error as Error).message
|
|
|
|
+
|
|
|
|
+ this.logger.error(
|
|
|
|
+ `Could not pass the request to ${serverUrl}/${endpointOrMethodIdentifier} on underlying service: ${JSON.stringify(
|
|
|
|
+ error,
|
|
|
|
+ )}`,
|
|
|
|
+ )
|
|
|
|
+
|
|
this.logger.debug('Response error: %O', (error as AxiosError).response ?? error)
|
|
this.logger.debug('Response error: %O', (error as AxiosError).response ?? error)
|
|
|
|
|
|
if ((error as AxiosError).response?.headers['content-type']) {
|
|
if ((error as AxiosError).response?.headers['content-type']) {
|