Skip to content

Commit bf5c1e2

Browse files
committed
chore: addressed comments
1 parent 50f787f commit bf5c1e2

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

packages/shield-controller/src/backend.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import { ConstantBackoff, HttpError } from '@metamask/controller-utils';
1+
import {
2+
ConstantBackoff,
3+
DEFAULT_MAX_RETRIES,
4+
HttpError,
5+
} from '@metamask/controller-utils';
26
import {
37
EthMethod,
48
SignatureRequestType,
@@ -333,7 +337,12 @@ function computePollingIntervalAndRetryCount(
333337
pollInterval: number,
334338
) {
335339
const backoff = new ConstantBackoff(pollInterval);
336-
const maxRetries = Math.floor(timeout / pollInterval) + 1;
340+
const computedMaxRetries = Math.floor(timeout / pollInterval) + 1;
341+
342+
const maxRetries = isNaN(computedMaxRetries)
343+
? DEFAULT_MAX_RETRIES
344+
: computedMaxRetries;
345+
337346
return {
338347
backoff,
339348
maxRetries,

packages/shield-controller/src/polling-with-policy.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ describe('PollingWithCockatielPolicy', () => {
8686
if (abortSignal.aborted) {
8787
reject(new Error('test error'));
8888
}
89-
reject(new Error('test error'));
89+
// eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors -- HttpError is a valid error which extends Error class
90+
reject(new HttpError(412, 'Results are not available yet'));
9091
}, 100);
9192
});
9293
});

0 commit comments

Comments
 (0)