Skip to content

Conversation

Aschen
Copy link
Contributor

@Aschen Aschen commented Jul 21, 2021

7.7.2 (2021-07-21)

Bug fixes

  • [ #651 ] Hotfix heartbeat race condition (Shiranuit)
  • [ #648 ] Fix the Jwt.expired getter wrong comparison of micro timestamp and timestamp (robingrandval)
  • [ #646 ] Fix usage of SearchResult.next with HTTP (Aschen)
  • [ #644 ] Correctly reject aborted queued requests (scottinet)

Enhancements

  • [ #650 ] Add authenticator function used at reconnection (Aschen)

scottinet and others added 8 commits June 2, 2021 13:05
When requests are queued, there are 2 constructor options that can lead to abort them before they can be sent to Kuzzle:

queueTTL: if set to a value larger than 0, queued requests can expire
queueMaxSize: if set to a value larger than 0, the queue has a maximum number of requests it can hold. If reached, older requests are aborted to make place for newer ones
When requests are aborted because of those configurations, an offlineQueuePop event is emitted, but:

the invalid argument is provided, making the event deliver an undefined payload
the promise associated to the aborted request is not rejected, making clients await indefinitely for them
This PR fixes these issues, and add the missing unit tests that should have caught these problems earlier.

Other changes
the offlineQueuePop event emitted when the queue is being played does not deliver the right payload. The entire queued object is delivered (containing the queued request and additional information about it), instead of just the request, as per the documentation. So, I fixed that too.
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:
- Avoid creating a Timeout in the the ping Interval since they had the same amount of time before execution and that caused  a race condition, we now only have an Interval that checks if there has been a pong since the last cycle, if not throw an Error, if there was a pong since the last ping cycle do another ping.
- Correct tests to verify the new behaviour
- Fixed: the ping Interval was not cleared when `websocket.close` was called
- Ensures that the websocket connection is closed on timeout before engaging the reconnection protocol otherwise if this was a false positive because Kuzzle could not respond in time we would have 2 connection opened.
- Ensures that the previous interval is cleared before creating a new one
When the SDK reconnect to Kuzzle, it trigger the `reconnected` event. The Realtime controller will try to resubscribe when this event is triggered.

If the token had expired, then the Realtime controller will try to resubscribe with no authentication and thus the subscriptions request may fail.

This PR include a new `authenticator` property, this property should contain a function that authenticate the SDK (with `auth.login` for example).  
The SDK will call the function before emitting the reconnected event, if the SDK was authenticated and cannot re-authenticate then the `reconnected` event will not be emitted and the SDK will be in the `disconnected` state.

A new `reconnectionError` has been added and is triggered when the reconnection has failed
@Aschen Aschen added the release label Jul 21, 2021
@codecov
Copy link

codecov bot commented Jul 21, 2021

Codecov Report

Merging #652 (0a9df3f) into master (68a346e) will increase coverage by 0.53%.
The diff coverage is 80.48%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #652      +/-   ##
==========================================
+ Coverage   85.62%   86.16%   +0.53%     
==========================================
  Files          36       36              
  Lines        1635     1662      +27     
  Branches      297      302       +5     
==========================================
+ Hits         1400     1432      +32     
+ Misses        175      173       -2     
+ Partials       60       57       -3     
Impacted Files Coverage Δ
src/core/searchResult/SearchResultBase.ts 77.58% <ø> (ø)
src/protocols/WebSocket.ts 78.57% <50.00%> (-2.11%) ⬇️
src/Kuzzle.ts 87.04% <100.00%> (+4.12%) ⬆️
src/core/Jwt.js 96.15% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 68a346e...0a9df3f. Read the comment docs.

@Aschen Aschen merged commit 8c7b354 into master Jul 21, 2021
@Aschen Aschen deleted the 7.7.2-proposal branch July 21, 2021 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants