Skip to content

Commit

Permalink
Remove unused retry parameter from safelyExecute (MetaMask#787)
Browse files Browse the repository at this point in the history
The `retry` parameter of `safelyExecute` was unused, so it has been
removed. Generally this parameter does not seem useful, and we are
trying to remove all uses of this function anyway.

This makes updating to TypeScript v4.4 slightly easier, because the
invocation of the retry function is a type error on that version
(because `error` is `unknown`).
  • Loading branch information
Gudahtt authored Apr 20, 2022
1 parent 480d682 commit 7256c7e
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 17 deletions.
14 changes: 0 additions & 14 deletions src/util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,20 +291,6 @@ describe('util', () => {
}),
).toBeUndefined();
});

it('should call retry function', async () => {
const mockRetry = jest.fn();
new Promise(() => {
util.safelyExecute(
() => {
throw new Error('ahh');
},
false,
mockRetry,
);
});
expect(mockRetry).toHaveBeenCalledWith(new Error('ahh'));
});
});

describe('safelyExecuteWithTimeout', () => {
Expand Down
3 changes: 0 additions & 3 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,13 +316,11 @@ export function normalizeTransaction(transaction: Transaction) {
*
* @param operation - Function returning a Promise.
* @param logError - Determines if the error should be logged.
* @param retry - Function called if an error is caught.
* @returns Promise resolving to the result of the async operation.
*/
export async function safelyExecute(
operation: () => Promise<any>,
logError = false,
retry?: (error: Error) => void,
) {
try {
return await operation();
Expand All @@ -331,7 +329,6 @@ export async function safelyExecute(
if (logError) {
console.error(error);
}
retry?.(error);
return undefined;
}
}
Expand Down

0 comments on commit 7256c7e

Please sign in to comment.