From aeb920381d04dd4a5f63aa2f1c6042984cf3a968 Mon Sep 17 00:00:00 2001 From: Alexandr Kazachenko Date: Sat, 14 Jan 2023 04:35:14 +0600 Subject: [PATCH] Ignore the MetaMask error with code 1013 (#653) * Ignore the MetaMask error with code 1013 The error 1013 shouldn't lead to wallet disconnect, because it's just an attempting to reestablish the connection * Use console.error instead of console.log * Updated link to Metamask release and log message * Fix code style --- packages/metamask/src/index.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/metamask/src/index.ts b/packages/metamask/src/index.ts index 5141093..04257c9 100644 --- a/packages/metamask/src/index.ts +++ b/packages/metamask/src/index.ts @@ -63,6 +63,12 @@ export class MetaMask extends Connector { }) this.provider.on('disconnect', (error: ProviderRpcError): void => { + // 1013 indicates that MetaMask is attempting to reestablish the connection + // https://github.com/MetaMask/providers/releases/tag/v8.0.0 + if (error.code === 1013) { + console.debug('MetaMask logged connection error 1013: "Try again later"') + return + } this.actions.resetState() this.onError?.(error) })