JoinColony / colonyCDapp

An iteration of the Colony Dapp sporting both a fully decentralized operating mode, as well as a mode enhanced by a metadata caching layer
5 stars 14 forks source link

Feat: Improve failed auth handling #3669

Open iamsamgibbs opened 1 week ago

iamsamgibbs commented 1 week ago

Description

This PR attempts to improve the way we handle failed mutations. There are few instances on QA and Production where actions were failing due to apollo 403 errors, the transaction would still succeed but the form would not proceed to the completed action screen due to the failed apollo calls. This meant the form could be resubmitted over and over resulting in multiple transactions.

It is likely these issues are caused by auth proxy rejecting the mutation. This can happen if auth proxy restarted after the saga has started running as the user will no longer be authenticated.

This PR attempts to improve this experiencing by adding a retry with re-authentication mechanism to all mutations and authentication attempts. If auth proxy rejects the mutation it will prompt the user to sign in again with metamask and reattempt the mutation. If the mutation still fails after this, the form will show an error message and the submit button will be disabled. This is a real edge case scenario and hopefully will never actually be seen in production.

Testing

This is going to be a bit of a pain to test I'm afraid and involves running a deliberately broken version of auth proxy locally to facilitate testing.

From this point on, if your wallet is disconnected and you end up getting kicked out of the colony, it may take a couple of attempts to reconnect the wallet. This is due to the auth proxy changes. I've not added retries to the main wallet connect authentication as we haven't had issues raised in this area.

https://github.com/user-attachments/assets/38da06c1-8678-4862-a198-ccaa3b0ed6e1

Compared to master, there is no automatic retry mechanism so the submit button will simply get stuck on "Pending" when a call fails.

https://github.com/user-attachments/assets/8c019c4a-641b-401a-8388-ce3e0ac1e954

Screenshot 2024-11-13 at 11 58 06

Further testing

Diffs

New stuff

Changes 🏗

TODO

Resolves #3523 Contributes to #3510

iamsamgibbs commented 3 days ago

Thanks for raising that @olgapod - I've refactored the functions to use exponential-backoff.

olgapod commented 2 hours ago

LGTM

image image