Update WalletConnect Provider to 6.1.5#1730
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the @multiversx/sdk-wallet-connect-provider dependency to version 6.1.5, increments the package version to 5.6.23, and updates the changelog. A critical issue was identified in the WalletConnect provider strategy where recursive calls in the reconnect method's error handler could lead to an infinite loop and application instability.
| "@multiversx/sdk-hw-provider": "8.1.2", | ||
| "@multiversx/sdk-native-auth-client": "2.0.1", | ||
| "@multiversx/sdk-wallet-connect-provider": "6.1.4", | ||
| "@multiversx/sdk-wallet-connect-provider": "6.1.5", |
There was a problem hiding this comment.
While updating this dependency, I noticed a potential critical issue in src/providers/strategies/WalletConnectProviderStrategy/WalletConnectProviderStrategy.ts that could lead to an infinite loop and application instability.
In the login method, if the initial login attempt fails, it calls reconnect(). The reconnect() method itself has a catch block that recursively calls reconnect() on any failure. This will cause an infinite loop if the connection or login continues to fail (for example, if the user repeatedly rejects the connection).
Here's the problematic code:
In login():
// src/providers/strategies/WalletConnectProviderStrategy/WalletConnectProviderStrategy.ts:257
} catch (error) {
console.error(WalletConnectV2Error.userRejected, error);
return await reconnect();
}In reconnect():
// src/providers/strategies/WalletConnectProviderStrategy/WalletConnectProviderStrategy.ts:237
} catch {
return await reconnect();
}To prevent this, I recommend removing the recursive call within the catch block of reconnect and instead re-throwing the error to be handled by the caller. This will prevent the infinite loop.
Suggested change in reconnect():
// src/providers/strategies/WalletConnectProviderStrategy/WalletConnectProviderStrategy.ts:237
} catch (err) {
console.error('WalletConnect reconnect failed', err);
throw err;
}
Issue/Feature
Reproduce
Issue exists on version
2.of sdk-dapp.Root cause
Fix
Additional changes
Contains breaking changes
Updated CHANGELOG
Testing