Skip to content

Conversation

@grdsdev
Copy link
Contributor

@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.

2 participants