-
Notifications
You must be signed in to change notification settings - Fork 662
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
KeepAlive: adds handling for cases when monitoring may be stopped #578
KeepAlive: adds handling for cases when monitoring may be stopped #578
Conversation
…ore the pong timeout related timers fire.
Codecov Report
@@ Coverage Diff @@
## master #578 +/- ##
=======================================
Coverage 86.78% 86.78%
=======================================
Files 6 6
Lines 280 280
Branches 43 43
=======================================
Hits 243 243
Misses 26 26
Partials 11 11
Continue to review full report at Codecov.
|
i disconnected my network connection to observe what happens. i don't see a crash, but i do some odd behavior:
immediately after the |
currently, the RTMClient depends on the behavior of calling i'm not sure whether this behavior is correct to expect. i can't find much in the spec about this, but from my read of the following test code, i think it should work: Update: actually, in the above test, its the server that initiates the closing of the websocket. according to the protocol specification, clients "SHOULD NOT" close the connection (but still may): https://tools.ietf.org/html/rfc6455#section-7.3. however, according to the DOM API, the close event should be fired: https://html.spec.whatwg.org/multipage/web-sockets.html#closeWebSocket Update 2: i think it is expected behavior: https://github.com/websockets/ws/blob/bf9b2ececbe42dd07ef9619d2b4953f57243c843/test/websocket.test.js#L1194-L1210. there's something to debug here. |
i think i figured it out! when you call |
*/ | ||
public start(client: RTMClient): void { | ||
this.logger.debug('start monitoring'); |
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.
Should we make these a little less vague so they make more sense in the context of all the other debug logging an app will be doing?
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 think this is okay since each log line is prepended with the object name (e.g. KeepAlive
), and in that context, monitoring only really has one meaning.
There has bee a crash reported that looks kind of like this:
After tracing how this might occur, one bad sequence of events was found: when
attemptAcknowledgePong()
gets called before theserverPongTimeout
but afterstop()
is already called, andstart()
has not been called yet.While the client is reconnecting, during the resuming state, incoming messages trigger
attemptAcknowledgePong()
(it was never removed from the EventEmitter) and then we run into an inconsistent state error. Breaking this into a separate method gives us the ability to remove it from the EventEmitter during the call tostop()
.After that issue was found, it became apparent that in all other places where we throw an inconsistent state error, we may similarly just be seeing a situation where monitoring was turned off before that callback fired. This PR also contains code to check
isMonitoring
in all of those situations, because its usually okay and just means we should return early.Requirements (place an
x
in each[ ]
)