-
Notifications
You must be signed in to change notification settings - Fork 0
Handle failures during socket connection #15
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
Handle failures during socket connection #15
Conversation
PR checklist ✅All required conditions are satisfied:
🎉 Great job! This PR is ready for review. |
407d817 to
f44391b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a bug where socket connection failures during handshake were not properly handled, causing coroutines to never complete. The fix overrides the onFailure method in the StreamWebSocketListener to properly propagate connection failures.
- Added
onFailurehandling in the handshake WebSocket listener to complete coroutines on connection errors - Added comprehensive test coverage for the socket connection failure scenario
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| StreamSocketSession.kt | Added onFailure override to handle socket connection failures during handshake |
| StreamSocketSessionTest.kt | Added test case and updated imports to verify proper failure handling behavior |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
...roid-core/src/test/java/io/getstream/android/core/internal/socket/StreamSocketSessionTest.kt
Show resolved
Hide resolved
f44391b to
1a0367e
Compare
VelikovPetar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
This reminded me, is closing the socket in this scenario a possible occurrence? I cannot think of a case where onClosed would be called here, but perhaps we should handle it as well - WDYT?
Good point! What do you think we should do in that case? Resume with a custom exception? Edit: done, let me know if it makes sense! |
Goal
We were missing onFailure handling during socket connection so, in case of errors there, we were never completing the coroutine
Implementation
Override onFailure for the
StreamWebSocketListenerused during connection.Testing
Try launching the sample without network connection and verify that the suspend function throws instead of never completing.
Checklist