-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Ensure readyState is set to SR_CLOSED on successful WebSocket closure #693
Ensure readyState is set to SR_CLOSED on successful WebSocket closure #693
Conversation
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.
Hi @nnabeyang, thanks for the contribution.
I think that the line you added is correct but not in the best place. I added a comment.
SocketRocket/SRWebSocket.m
Outdated
@@ -1113,6 +1113,8 @@ - (void)_pumpWriting | |||
} | |||
} | |||
|
|||
self.readyState = SR_CLOSED; |
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.
Shouldn't this code go inside the if(!_failed)
?
What's the state of the WebSocket if we send a command to close it and it fails to close for whatever reason? Is it in closing state? is it open?
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.
@cipolleschi Thank you! You're right, it does make more sense to put it inside if(!_failed)
. I fixed it.
@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
@cipolleschi merged this pull request in 2204e53. |
…facebookincubator#693) Summary: This PR fixes an issue where the `readyState` was not properly set to `SR_CLOSED` when the WebSocket closed successfully. ### Changes: - Previously, during a successful WebSocket closure, the `readyState` remained at `SR_CLOSING` and was not updated to `SR_CLOSED`. - With this fix, the `readyState` is now set to `SR_CLOSED` before the delegate method responsible for handling the WebSocket closure is called. Pull Request resolved: facebookincubator#693 Reviewed By: nlutsenko Differential Revision: D64108852 Pulled By: cipolleschi fbshipit-source-id: d683d951e3b0069f1e909c091e8bc4e5d5066dab
This PR fixes an issue where the
readyState
was not properly set toSR_CLOSED
when the WebSocket closed successfully.Changes:
readyState
remained atSR_CLOSING
and was not updated toSR_CLOSED
.readyState
is now set toSR_CLOSED
before the delegate method responsible for handling the WebSocket closure is called.