- 
                Notifications
    You must be signed in to change notification settings 
- Fork 17
Hotfix heartbeat race condition #651
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
Conversation
| Codecov Report
 @@            Coverage Diff             @@
##            7-dev     #651      +/-   ##
==========================================
+ Coverage   85.62%   86.00%   +0.38%     
==========================================
  Files          36       36              
  Lines        1635     1644       +9     
  Branches      297      298       +1     
==========================================
+ Hits         1400     1414      +14     
+ Misses        175      173       -2     
+ Partials       60       57       -3     
 Continue to review full report at Codecov. 
 | 
        
          
                src/protocols/WebSocket.ts
              
                Outdated
          
        
      | if (this.client && | ||
| this.client.readyState === this.client.OPEN && | ||
| !this.waitForPong | ||
| ) { | 
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.
Wrong coding standards here, the && should be at the beginning
# [7.7.2](https://github.com/kuzzleio/sdk-javascript/releases/tag/7.7.2) (2021-07-21) #### Bug fixes - [ [#651](#651) ] Hotfix heartbeat race condition ([Shiranuit](https://github.com/Shiranuit)) - [ [#648](#648) ] Fix the Jwt.expired getter wrong comparison of micro timestamp and timestamp ([robingrandval](https://github.com/robingrandval)) - [ [#646](#646) ] Fix usage of SearchResult.next with HTTP ([Aschen](https://github.com/Aschen)) - [ [#644](#644) ] Correctly reject aborted queued requests ([scottinet](https://github.com/scottinet)) #### Enhancements - [ [#650](#650) ] Add authenticator function used at reconnection ([Aschen](https://github.com/Aschen)) ---
What does this PR do ?
This PR fixes a Race Condition that was occuring within the Heartbeat causing the SDK to think the connection was lost and making him engage the reconnection protocol which was causing the SDK to create multiple Websocket connection even though the previous connections were fine.
This is a serious problem that could cause applications to be overloaded with Websocket connections and can saturate the Event Loop or the limit of Websocket connections defined by the browsers.
What has been done:
websocket.closewas calledHow should this be manually tested
Run this script, there should not be any network error messages, and only one active websocket connection to kuzzle.
Unfortunately this doesn't help testing the
Race Conditionas it's not easy to reproduce the exact conditions needed, but it somehow occurs frequently in one of our project.