-
Notifications
You must be signed in to change notification settings - Fork 394
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change current provider on timeouted RPC requests (#3587)
### What If some RPC request fails because of a timeout we should change to a different RPC provider. Tested on reproduced problem with `ankr` RPC #### TODO: - [x] `await this.currentProvider.send(method, params)` - is swallowing 429 request's error, can we rethrow it so we don't have to wait for timeouts? - [x] we should loop providers - if the last provider on the list has been used let's set the first provider as current - lmk if you think it is a good idea 🤔 ## How to test - Patch default providers https://github.com/tahowallet/extension/blob/7c88a8629088ce2e718e5cbc48571f99534f1a03/background/constants/networks.ts#L185 using `patchRPCURLS` from https://github.com/tahowallet/extension/blob/7c88a8629088ce2e718e5cbc48571f99534f1a03/scripts/unreliable-rpc-provider-utils.ts - Run `node scripts/unreliable-rpc-provider.mjs` - Reinstall the extension, open the background inspector and check that providers are being switched on timeouts/server errors - Onboard an account, perform a few actions. Verify the wallet is handling errors gracefully Latest build: [extension-builds-3587](https://github.com/tahowallet/extension/suites/14751539578/artifacts/838585130) (as of Wed, 02 Aug 2023 07:27:53 GMT).
- Loading branch information
Showing
6 changed files
with
237 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export const patchRPCURL = (url: string): string => | ||
`http://localhost:9000?rpc=${url}` | ||
|
||
export const patchRPCURLS = ( | ||
chainIDToRPCMap: Record<string, string[]> | ||
): typeof chainIDToRPCMap => | ||
Object.fromEntries( | ||
Object.entries(chainIDToRPCMap).map(([_, urls]) => [ | ||
_, | ||
urls.map(patchRPCURL), | ||
]) | ||
) |
Oops, something went wrong.