-
Notifications
You must be signed in to change notification settings - Fork 845
Fixed loosing POST packets on web socket connection failure #1034
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
Fixed loosing POST packets on web socket connection failure #1034
Conversation
…e memory leak on server errors.
@@ -371,6 +371,9 @@ open class SocketEngine : NSObject, URLSessionDelegate, SocketEnginePollable, So | |||
fastUpgrade = false | |||
probing = false | |||
flushProbeWait() | |||
if postWait.count != 0 { |
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.
How about a !.isEmpty
?
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.
No problem, I just copied existing code.
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.
Or maybe move that check into flush... as a guard and unconditionally call it?
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.
It was in flushProbeWait(). That was the problem since this method needs to be called on web socket success and failure, but flushWaitingForPostToWebSocket() only on success. If called on failure, POST packets are just dropped into failed socket.
Another way will be to check in flushWaitingForPostToWebSocket() if socket is connected.
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.
I'm fine with this way in that case! Would you mind also adding some documentation comments to these methods that explain this failure case? I think those will be helpful when I come back in 6 months and try to refactor and end up breaking it again :).
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.
👌 will also change to !.isEmpty
and test
Fixed loosing POST packets on web socket connection failure and engine memory leak on server errors.