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

Relay client connect throws Bad state: Stream has already been listened to #66

Open
AlexV525 opened this issue Dec 25, 2024 · 5 comments · May be fixed by #67
Open

Relay client connect throws Bad state: Stream has already been listened to #66

AlexV525 opened this issue Dec 25, 2024 · 5 comments · May be fixed by #67

Comments

@AlexV525
Copy link
Contributor

SDK Affected: WalletKit

Describe the bug

We got tons of reports in our production app.

Stack trace
onRelayClientError: Bad state: Stream has already been listened to.
#0      _StreamController._subscribe (dart:async/stream_controller.dart:686)
#1      _ControllerStream._createSubscription (dart:async/stream_controller.dart:837)
#2      _StreamImpl.listen (dart:async/stream_impl.dart:497)
#3      _CompleterStream.listen (package:async/src/stream_completer.dart:135)
#4      new _ForwardingStreamSubscription (dart:async/stream_pipe.dart:114)
#5      _ForwardingStream._createSubscription (dart:async/stream_pipe.dart:86)
#6      _ForwardingStream.listen (dart:async/stream_pipe.dart:81)
#7      CastStream.listen (dart:_internal/async_cast.dart:17)
#8      new _ForwardingStreamSubscription (dart:async/stream_pipe.dart:114)
#9      _ForwardingStream._createSubscription (dart:async/stream_pipe.dart:86)
#10     _ForwardingStream.listen (dart:async/stream_pipe.dart:81)
#11     _CloseGuaranteeStream.listen (package:stream_channel/src/close_guarantee_channel.dart:60)
#12     new _ForwardingStreamSubscription (dart:async/stream_pipe.dart:114)
#13     _ForwardingStream._createSubscription (dart:async/stream_pipe.dart:86)
#14     _ForwardingStream.listen (dart:async/stream_pipe.dart:81)
#15     _CloseGuaranteeStream.listen (package:stream_channel/src/close_guarantee_channel.dart:60)
#16     Peer.listen (package:reown_core/relay_client/json_rpc_2/src/peer.dart:123)
#17     RelayClient._createJsonRPCProvider (package:reown_core/relay_client/relay_client.dart:290)
<asynchronous suspension>
#18     RelayClient._connect (package:reown_core/relay_client/relay_client.dart:212)
<asynchronous suspension>
#19     RelayClient.connect (package:reown_core/relay_client/relay_client.dart:179)
<asynchronous suspension>

The _stream is only for a single subscription.

To Reproduce

Call the peer.listen multiple times would probably reproduce the issue.

Copy link

linear bot commented Dec 25, 2024

@AlexV525 AlexV525 linked a pull request Dec 25, 2024 that will close this issue
@quetool
Copy link
Member

quetool commented Dec 30, 2024

Hello @AlexV525, can you share steps to reproduce this or some minimal reproducible code? We have no other reports about this from other devs/customers.
Furthermore, your PR is failing on integration tests, you can check by running flutter test --dart-define=RELAY_ENDPOINT=wss://relay.walletconnect.org --dart-define=PROJECT_ID=cad4956f31a5e40a00b62865b030c6f8 inside reown_core package

@AlexV525
Copy link
Contributor Author

AlexV525 commented Dec 31, 2024

Hello @AlexV525, can you share steps to reproduce this or some minimal reproducible code? We have no other reports about this from other devs/customers.

From our timeline, this usually happens when the user has a poor network condition that might get stuck when connecting to the relay endpoint, so the _connect was called multiple times.

Furthermore, your PR is failing on integration tests, you can check by running flutter test --dart-define=RELAY_ENDPOINT=wss://relay.walletconnect.org --dart-define=PROJECT_ID=cad4956f31a5e40a00b62865b030c6f8 inside reown_core package

The PR has been updated. Would you like me to integrate it with the GitHub CI?

@quetool
Copy link
Member

quetool commented Dec 31, 2024

The PR has been updated. Would you like me to integrate it with the GitHub CI?

No need, I just wanted you to check the tests, since this is the core package we are extra sensitive about it.

Thanks! I'll check it properly ASAP

@AlexV525
Copy link
Contributor Author

No need, I just wanted you to check the tests, since this is the core package we are extra sensitive about it.

After some looks I felt it would be good to integrate with.

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 a pull request may close this issue.

2 participants