Improve isSocketClosingOrClosed Check to Handle WebSocket.CONNECTING State#83
Open
shahzaib-deriv wants to merge 3 commits into
Open
Conversation
yashim-deriv
reviewed
Oct 9, 2024
yashim-deriv
left a comment
Contributor
There was a problem hiding this comment.
nit on naming. the rest lgtm
hasan-deriv
approved these changes
Oct 18, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description:
In the current implementation of the isSocketClosingOrClosed method, the state of the WebSocket connection is checked using the following logic:
This condition currently checks if the WebSocket connection is in the CLOSED (3) or CLOSING (2) states but does not handle the CONNECTING (0) state. As a result, if send is called while the WebSocket is still in the
CONNECTINGstate, it may throw an error.Suggested Improvement:
To enhance robustness, updating the condition to explicitly account for the
CONNECTINGstate as follows:This modification would prevent sending messages when the WebSocket is not fully open, reducing the likelihood of encountering runtime errors and improving the overall stability of the application.