From 7abd80cdbaba53840f632d418bd557b35b722699 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20S=C3=B3jko?= Date: Thu, 4 Jan 2024 19:13:13 +0100 Subject: [PATCH] fix(api-gateway): disable http call retries --- .../src/Service/Http/HttpServiceProxy.ts | 21 +------------------ 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/packages/api-gateway/src/Service/Http/HttpServiceProxy.ts b/packages/api-gateway/src/Service/Http/HttpServiceProxy.ts index 73a1e512b..f16ed5f30 100644 --- a/packages/api-gateway/src/Service/Http/HttpServiceProxy.ts +++ b/packages/api-gateway/src/Service/Http/HttpServiceProxy.ts @@ -175,7 +175,6 @@ export class HttpServiceProxy implements ServiceProxyInterface { response: Response, endpoint: string, payload?: Record | string, - retryAttempt?: number, ): Promise { try { const headers: Record = {} @@ -213,33 +212,15 @@ export class HttpServiceProxy implements ServiceProxyInterface { await this.crossServiceTokenCache.invalidate(userUuid) } - if (retryAttempt) { - this.logger.debug(`Request to ${serverUrl}/${endpoint} succeeded after ${retryAttempt} retries`) - } - return serviceResponse } catch (error) { - const requestDidNotMakeIt = this.requestTimedOutOrDidNotReachDestination(error as Record) - const tooManyRetryAttempts = retryAttempt && retryAttempt > 2 - if (!tooManyRetryAttempts && requestDidNotMakeIt) { - await this.timer.sleep(50) - - const nextRetryAttempt = retryAttempt ? retryAttempt + 1 : 1 - - this.logger.debug(`Retrying request to ${serverUrl}/${endpoint} for the ${nextRetryAttempt} time`) - - return this.getServerResponse(serverUrl, request, response, endpoint, payload, nextRetryAttempt) - } - let detailedErrorMessage = (error as Error).message if (error instanceof AxiosError) { detailedErrorMessage = `Status: ${error.status}, code: ${error.code}, message: ${error.message}` } this.logger.error( - tooManyRetryAttempts - ? `Request to ${serverUrl}/${endpoint} timed out after ${retryAttempt} retries` - : `Could not pass the request to ${serverUrl}/${endpoint} on underlying service: ${detailedErrorMessage}`, + `Could not pass the request to ${serverUrl}/${endpoint} on underlying service: ${detailedErrorMessage}`, { userId: response.locals.user ? response.locals.user.uuid : undefined, },