Skip to content

Conversation

@defuncart
Copy link
Contributor

Hi @konsultaner, thanks for creating this package.

I noticed in lib/src/transport/websocket/websocket_transport_io.dart, complete is used from lib/src/transport/abstract_transport.dart

complete(_onDisconnect, error);

complete is also used in lib/src/transport/websocket/websocket_transport_web.dart to close _onConnectionLost, _onDisconnect.

This PR aligns websocket_transport_io to use complete over manual completion, e.g.

-   _onConnectionLost!.complete();
+   complete(_onConnectionLost, null);

In the case of _onConnectionLost!.complete() being called multiple times, this results in Unhandled Exception: Bad state: Future already completed errors as a completer should only be completed once. The existing method complete explicitly checks if the completer has already been completed before invoking complete.

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.

1 participant