diff --git a/index.js b/index.js index 09ba5f8..3fddc94 100644 --- a/index.js +++ b/index.js @@ -59,7 +59,18 @@ async function main() { data: response.data }); } catch (error) { - console.error(error); + if (RETRY_ERROR_CODES.includes(error.response.status)) { + console.log(`Retrying request ${requestObj.id} for instance ${instanceId}`); + SetTimeout(() => { + DoRequest(instanceId, requestObj); + }, 5000); + } else { + RegisterResponse(instanceId, { + id: requestObj.id, + data: error.response.data, + error: "yep there was an error" + }); + } } }