lens-protocol/lens-sdk

In the useLogin react hook, when the user cancel the signing message modal, an unhandled promise is being thrown instead of being handled by the SDK

pradel opened this issue ยท 14 comments

pradel commented

Describe the bug

In the useLogin hook, the SDK does not handle the signing message error properly. When the user rejects the sign message in their wallet, the error is not reported here but thrown as an unhandled promise rejection.

To Reproduce

  1. go to https://lens-sdk-example-web-wagmi.vercel.app/login
  2. click to login and select the profile
  3. get the sign message popup from your wallet and cancel the request
  4. see the unhandled promise in the console

Expected behaviour

The error should be catched and returned by the isFailure function

If using the React bindings, what is the essence of your React app?

  • React Web App
  • React Native

Version of the packages you are using

"@lens-protocol/react-web": "2.0.0-alpha.19"

thanks for raising this @pradel

i was able to reproduce this, thanks for the detailed reproduction steps.

we are taking a look into the cause now.

i will keep update this issue once resolved ๐Ÿ‘

@pradel see mentioned PR for small fix that better handles this error

this is not related directly to our React SDK but more so an issue with our example app using wagmi and viem

we do already handle the case where a user rejects the request in the login flow

this error was coming from before the login flow was executed, in the connection of the wallet to example app

i've added an onError callback to this example to better handle this case

@reecejohnson from my tests the error is coming from the login flow (when you sign a message), not the connect flow. It was working properly with the V1 of the SDK but not with the V2 so maybe a regression?

@pradel i see, can you provide some information around which wallet you're using? and a screen recording if possible

@pradel any update on this?

The issue is still happening with the latest version, I am using Taho Wallet and it can be reproduced in the lens example consistently https://lens-sdk-example-web-wagmi.vercel.app/login

@cesarenaldi @reecejohnson this is the video showing the issue I am facing.

Screen.Recording.2024-01-03.at.19.08.02.mov

@pradel thank you for the video, this is now more clear. Internally the SDK uses ethers.js, it seems something is not working with the RPC wallet error codes and ethers.js error codes mapping.

We will need to investigate this further to assess if this can be patched or requires to upgrade ethers.

We will get back to you when we know more. Thank u for now.

@pradel we will be able to allocate proper time to look into this next week.

I understand this is happening only in the very particular circumstance that a user refuse (from their Taho Wallet) to sign the login challenge text. So seems to not affect the rest of the app experience when the user wants instead to continue w/ login. Is this correct?

Correct, it's not critical as the user can continue the flow as usual.

@cesarenaldi just tested with Rabby wallet and the same issue is happening. I think this used to work fine with the v1 of the SDK but not 100% sure.

Hey @pradel thank you, I managed to spot the issue using Rabby. Will include a fix in the next SDK release.

Fix for this available in: @lens-protocol/react-native@0.1.0-alpha.5 and @lens-protocol/react-web@2.0.0-alpha.28