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

[Crash] SDK crashes when disconnect from topic #596

Closed
lmcmz opened this issue Nov 16, 2022 · 15 comments
Closed

[Crash] SDK crashes when disconnect from topic #596

lmcmz opened this issue Nov 16, 2022 · 15 comments
Labels
bug Something isn't working

Comments

@lmcmz
Copy link

lmcmz commented Nov 16, 2022

Describe the bug
When disconnecting from topic, SDK crashes sometime.

WalletConnectNetworking/NetworkingInteractor.swift:98: Fatal error: 'try!' expression unexpectedly raised an error: WalletConnectKMS.Serializer.Errors.symmetricKeyForTopicNotFound
2022-11-17 07:59:43.276879+1100 Dapper Pro[40117:9253430] WalletConnectNetworking/NetworkingInteractor.swift:98: Fatal error: 'try!' expression unexpectedly raised an error: WalletConnectKMS.Serializer.Errors.symmetricKeyForTopicNotFound

SDK Version

  • Client: Swift
  • Version: 1.0.5

To Reproduce
Steps to reproduce the behavior:

  1. Go to a dApp
  2. Make a connection
  3. Disconnect from the topic
  4. Disconnect again from the topic

Expected behavior
The pairing or session need to be removed from the list

Screenshots
Screenshot 2022-11-17 at 8 00 25 am

Device:

  • Device: iPhone12 Pro Max
  • OS: iOS16
@lmcmz lmcmz added the bug Something isn't working label Nov 16, 2022
@llbartekll
Copy link
Contributor

llbartekll commented Nov 17, 2022

  1. Disconnect from the topic
  2. Disconnect again from the topic

Hey @lmcmz why do you disconnect from the same topic twice?

edit: anyway it should not crash

@lmcmz
Copy link
Author

lmcmz commented Nov 17, 2022

Hey @llbartekll,

After we disconnect from the topic, it seem like it will still stay in the list of settled session -> Sign.instance.getSessions().
Which cause the disconnect twice, user got confused, since first disconnect won't remove it from the list then it got crash.

@llbartekll
Copy link
Contributor

do you subscribe to sessionDeletePublisher?

@llbartekll
Copy link
Contributor

does it happen in your project? because I cannot reproduce it in sample app.

@lmcmz
Copy link
Author

lmcmz commented Nov 17, 2022

Yes, it happens in my project. Somehow, some sessions in the list can't be disconnected, and it keeps in the list (Sign.instance.getSessions).

@llbartekll
Copy link
Contributor

ok but does sessionDeletePublisher publish when you call disconnect() with the first time?

@llbartekll
Copy link
Contributor

btw. does disconnect() throws an error when you call it with the first time?

@lmcmz
Copy link
Author

lmcmz commented Nov 24, 2022

I will keep an eye on it. But I do reproduce the disconnect crash frequently, it's kinda annoying since some of the connections will never be able to disconnect.

is there a quick fix that we should remove the force try! in any place in the SDK ?

@llbartekll
Copy link
Contributor

hey, the crash is fixed, we will release a new version tomorrow so you can upgrade.

it's kinda annoying since some of the connections will never be able to disconnect.

I think it won't happen. I believe you were calling a function twice and there were keys removed after a second call, so function did not throw immediately and tried to remove a keys with the second call too. Now it will just throw an error.

@llbartekll
Copy link
Contributor

if you like you can test on develop branch already

@lmcmz
Copy link
Author

lmcmz commented Nov 29, 2022

Hey @llbartekll,
Thanks for the fix, it's not crashing.
But the disconnect issue is still persistent, after the wallet sends deleting request, the connection is still in the session list.

From what I observed the sessionDeletePublisher is not triggering for the first time.
but the dApp has received for the deletion request

EVENT pairing_delete {id: 1669726832666843, topic: 'fd0c42600f03f55e18f193eaf985380e06903283d6936602b743e255bc6486ae'}

@lmcmz
Copy link
Author

lmcmz commented Nov 29, 2022

It seem like there is some different behavior between Sign.instance.disconnect and Pair.instance.disconnect.
Mainly, I can reproduce it with Pair.instance.

@llbartekll
Copy link
Contributor

llbartekll commented Nov 30, 2022

@lmcmz

But the disconnect issue is still persistent, after the wallet sends deleting request, the connection is still in the session list.

try await Sign.instance.disconnect
//here the session has already disappeared

the function is async and if it does not throw and will return it means that the session has been removed, so you can querry sessions and update your list

It seem like there is some different behavior between Sign.instance.disconnect and Pair.instance.disconnect.

it is different behaviour because Pair.instance.disconnect disconnects pairings not sessions, those are two different object types

@llbartekll
Copy link
Contributor

@lmcmz can we cole the issue?

@lmcmz
Copy link
Author

lmcmz commented Dec 1, 2022

Yeah, let's close it for now.
I will re-open it, once I meet it again.

@lmcmz lmcmz closed this as completed Dec 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants