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(realtime): web socket message listener doesn't stop #284

Merged
merged 2 commits into from
Mar 28, 2024

Conversation

grdsdev
Copy link
Collaborator

@grdsdev grdsdev commented Mar 28, 2024

What kind of change does this PR introduce?

Bug fix

What is the current behavior?

When the WebSocket is closed by the client, the listener for messages doesn't stop.

What is the new behavior?

By wrapping the web socket task in a SocketStream class that exposes a custom cancel method, we make sure to finish the stream when canceling the socket connection on the client side.

Additional context

There are some caveats when wrapping WebSocket in async/await, but thanks to https://www.donnywals.com/iterating-over-web-socket-messages-with-async-await-in-swift/ this PR fixes it.

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