Skip to content

Commit 4cb6a1b

Browse files
ebadiereAlfredoG87
andauthored
change so we only retry on 404s if a retry is desired (#1194) (#1206)
* change so we only retry on 404s if a retry is desired * moved the retryable codes to the mirrorNodeClient.ts and make it a configurable list with default being only 404 * refactored const name so is more descriptive to mirrorNodeRetryErrorCodes --------- Signed-off-by: Alfredo Gutierrez <[email protected]> Signed-off-by: ebadiere <[email protected]> Co-authored-by: Alfredo Gutierrez <[email protected]>
1 parent f3bd80b commit 4cb6a1b

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

docs/configuration.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ The following table lists the available properties along with their default valu
4242
Unless you need to set a non-default value, it is recommended to only populate overridden properties in the custom `.env`.
4343

4444
| Name | Default | Description |
45-
| ------------------------------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
45+
|---------------------------------------| ------------- |--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
4646
| `CLIENT_TRANSPORT_SECURITY` | "false" | Flag to enable or disable TLS for both networks. |
4747
| `CONSENSUS_MAX_EXECUTION_TIME` | "15000" | Maximum time in ms the SDK will wait when submitting a transaction/query before throwing a TIMEOUT error. |
4848
| `DEFAULT_RATE_LIMIT` | "200" | default fallback rate limit, if no other is configured. |
@@ -57,6 +57,7 @@ Unless you need to set a non-default value, it is recommended to only populate o
5757
| `LIMIT_DURATION` | "60000" | The maximum duration in ms applied to IP-method based rate limits. |
5858
| `MIRROR_NODE_LIMIT_PARAM` | "100" | The mirror node custom limit value to be set on GET requests. This optimizes the flow to reduce the number of calls made to the mirror node by setting a limit larger than it's default limit. |
5959
| `MIRROR_NODE_RETRIES` | "3" | The maximum number of retries on a GET request to the mirror node when an acceptable error code is returned. |
60+
| `MIRROR_NODE_RETRY_CODES` | "[404]" | The acceptable error codes to retry on a request to the mirror node. If more than 1 error is defined value should be like ie: [400,404,500] |
6061
| `MIRROR_NODE_RETRY_DELAY` | "250" | The delay in ms between retry requests. |
6162
| `MIRROR_NODE_RETRIES_DEVMODE` | "5" | The maximum number of retries on a GET request to the mirror node when an acceptable error code is returned in dev mode. |
6263
| `MIRROR_NODE_RETRY_DELAY_DEVMODE` | "200" | The delay in ms between retry requests in dev mode. |

packages/relay/src/lib/clients/mirrorNodeClient.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ export class MirrorNodeClient {
147147
const mirrorNodeRetriesDevMode = parseInt(process.env.MIRROR_NODE_RETRIES_DEVMODE!) || 5;
148148
const mirrorNodeRetryDelay = parseInt(process.env.MIRROR_NODE_RETRY_DELAY!) || 250;
149149
const mirrorNodeRetryDelayDevMode = parseInt(process.env.MIRROR_NODE_RETRY_DELAY_DEVMODE!) || 200;
150+
const mirrorNodeRetryErrorCodes: Array<number> = process.env.MIRROR_NODE_RETRY_CODES ? JSON.parse(process.env.MIRROR_NODE_RETRY_CODES) : [404]; // by default we should only retry on 404 errors
150151

151152
const axiosClient: AxiosInstance = Axios.create({
152153
baseURL: baseUrl,
@@ -184,7 +185,7 @@ export class MirrorNodeClient {
184185
return delay;
185186
},
186187
retryCondition: (error) => {
187-
return !error?.response?.status || MirrorNodeClientError.retryErrorCodes.includes(error?.response?.status);
188+
return !error?.response?.status || mirrorNodeRetryErrorCodes.includes(error?.response?.status);
188189
},
189190
shouldResetTimeout: true
190191
});

packages/relay/src/lib/errors/MirrorNodeClientError.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ export class MirrorNodeClientError extends Error {
2323
public statusCode: number;
2424
public errorMessage?: string;
2525

26-
static retryErrorCodes: Array<number> = [400, 404, 408, 425, 500]
27-
2826
static ErrorCodes = {
2927
ECONNABORTED: 504,
3028
CONTRACT_REVERT_EXECUTED : 400,

0 commit comments

Comments
 (0)