Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] killSession not working, #84 #85

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

WingCH
Copy link

@WingCH WingCH commented Nov 5, 2022

fix #84

The problem is caused by the use of unawaited, I think it is because the killSession request will not have any response and the author wants to run killSession and then use _handleSessionDisconnect to reset the local state immediately.
Unfortunately, the actual situation is that the local state is reset before the killSession request is sent out, so a valid killSession request cannot be sent successfully.

Future killSession({String? sessionError}) async {
   ...
   unawaited(_sendRequest(request));
   await _handleSessionDisconnect(errorMessage: message, forceClose: true);
   ..
}

To reduce the impact on other places, I just add a delay to ensure that the killSession request can be sent out before the _handleSessionDisconnect reset local state.

unawaited(_sendRequest(request));
// Avoid starting `_handleSessionDisconnect` before completing `_sendRequest`, which will cause the dapp to not be disconnected from the wallet, https://github.com/RootSoft/walletconnect-dart-sdk/issues/84
await Future.delayed(const Duration(milliseconds: 100));
await _handleSessionDisconnect(errorMessage: message, forceClose: true);

Hope to approve this PR, please let me know if there are any problems 🙏🏻 Thanks so much

@Neo-vortex
Copy link

await Future.delayed(const Duration(milliseconds: 100));
is always guaranteed to work?
hard coding a 100 ms doesn't seem to be very attractive

@WingCH
Copy link
Author

WingCH commented Nov 11, 2022

I have tested on my android and ios device, btw I know it's just a workaround solution.

Author should come up with a better solution

#84 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[iOS][Android]Cannot disconnect wallet after use killSession
2 participants