From 33f51ba7caeff773deebe49fd964cc69ca1ecc2e Mon Sep 17 00:00:00 2001 From: Abhimanyu Babbar Date: Thu, 13 Jun 2024 22:40:13 +0530 Subject: [PATCH] fix: restructured the code to throw retryable code everytime in case of unexpected error --- src/util/openfaas/index.js | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/util/openfaas/index.js b/src/util/openfaas/index.js index d05199a387..9b4599fad1 100644 --- a/src/util/openfaas/index.js +++ b/src/util/openfaas/index.js @@ -339,24 +339,15 @@ const executeFaasFunction = async ( return await invokeFunction(name, events); } catch (error) { logger.error(`Error while invoking ${name}: ${error.message}`); - errorRaised = error; + errorRaised = error; if (error.statusCode === 404 && error.message.includes(`error finding function ${name}`)) { removeFunctionFromCache(name); - await setupFaasFunction(name, null, versionId, libraryVersionIDs, testMode, trMetadata); - throw new RetryRequestError(`${name} not found`); } - if (gatewayRetriableStatus.includes(error.statusCode)) { - if (error.statusCode === 429) { - throw new RetryRequestError(`Rate limit exceeded for ${name}`); - } - - throw new RetryRequestError(error.message); - } - - throw error; + // all unexpected errors are retried at caller + throw new RetryRequestError(error.message); } finally { // delete the function created, if it's called as part of testMode if (testMode) {