Skip to content
This repository has been archived by the owner on Jun 24, 2022. It is now read-only.

Add waiting time to reconnection #2526

Merged
merged 4 commits into from
Mar 9, 2022
Merged

Conversation

henrypalacios
Copy link
Contributor

@henrypalacios henrypalacios commented Mar 4, 2022

Summary

Closes #2514

Stop the connecting... status and delete the lastProvider from storage after 15sec without success

@henrypalacios henrypalacios added app:CowSwap CowSwap app Protofire Handled by Protofire development team labels Mar 4, 2022
@henrypalacios henrypalacios self-assigned this Mar 4, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2022

CLA Assistant Lite All Contributors have signed the CLA.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2022

  • 🔭 GP Swap: CoW Protocol v2 Swap UI

@elena-zh
Copy link

elena-zh commented Mar 4, 2022

Hey @henrypalacios , great ideas!
One that I like most is that the counter ends, connection stops.

However, I'd like to propose not to change 'Conneting...' state to 'Trying to connect', as it is truncated in the desktop view, + counter is not visible.
image

Maybe we do not need to show the counter at all. just to keep 'Connecting' state up to 15 sec, then stop it and show 'Error connecting' pop-up with the last connected wallet info
image

@alfetopito , WDYT?

@alfetopito
Copy link
Contributor

Yep, agree with Elena's suggestions.

Keep the same text as before (Connecting) without a counter.

@henrypalacios
Copy link
Contributor Author

@elena-zh, after discussing it with @alfetopito, I'll leave this PR up to here without fulfilling the last part you suggest:

then stop it and show 'Error connecting' pop-up with the last connected wallet info
image

would requires some data states to be uploaded of level and will make this PR grow much more.

@henrypalacios henrypalacios merged commit 81a74ad into develop Mar 9, 2022
@henrypalacios henrypalacios deleted the 2514-hangs-connecting branch March 9, 2022 00:25
@github-actions github-actions bot locked and limited conversation to collaborators Mar 9, 2022
@elena-zh
Copy link

elena-zh commented Mar 9, 2022

Hey @henrypalacios , great changes.
I have to notice, that by this fix you also fixed #1187 issue.

Also, I have created a related low priority related issue that might be good to fix in the future #2530

src/constants/wallet.ts Show resolved Hide resolved
if (active) {
setTried(true)
} else {
timeout = setTimeout(() => {
localStorage.removeItem(STORAGE_KEY_LAST_PROVIDER)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get it. Why do we need to add this? maybe a comment would help to understand.

Copy link
Contributor Author

@henrypalacios henrypalacios Mar 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The last provider is stored before the unload component.

After a page reload when trying to reconnect a wallet from an external provider such as Fortmatic or CoinbaseWallet we have no way of knowing if the session was cut off.

The timeout would be the time we wait while the external provider reconnects the session, otherwise we assume that it has been tried, there is no lastProvider and the user can open walletModals.

Copy link
Contributor Author

@henrypalacios henrypalacios Mar 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking about it, maybe it makes more sense that this timeout logic is inside the reconnectProvider and this way it is only executed when there is a lastProvider.

I can do this together with #2515 but let me know if you have any suggestion on this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't fully get it TBH. In principle seems like a fragile logic. Also, i was referring to adding a comment in the code too

Maybe i would understand describing the sequence of events, and why we really need this timeout logic

}

return () => timeout && clearTimeout(timeout)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we clear the timeout? I understand we don't want to do the setTried but, if you clear it you won't do the removeItem

Copy link
Contributor Author

@henrypalacios henrypalacios Mar 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The clearTimeout is because if during the waiting time the provider changes its active sate, it would no longer need to remove the lastProvider.

And ultimately removeItem will be executed by handleBeforeUnload

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
app:CowSwap CowSwap app Protofire Handled by Protofire development team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Coinbase wallet: The app hangs in the 'Connecting...' state when close connection modal
4 participants