-
Notifications
You must be signed in to change notification settings - Fork 17
Prevent pending request leak when disconnect the SDK #424
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 @@
## 6-dev #424 +/- ##
==========================================
+ Coverage 96.31% 96.33% +0.02%
==========================================
Files 32 32
Lines 1520 1529 +9
==========================================
+ Hits 1464 1473 +9
Misses 56 56
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## 6-dev #424 +/- ##
=========================================
+ Coverage 96.31% 96.41% +0.1%
=========================================
Files 32 32
Lines 1520 1535 +15
=========================================
+ Hits 1464 1480 +16
+ Misses 56 55 -1
Continue to review full report at Codecov.
|
* Emits an event for each discarded pending request. | ||
*/ | ||
clear () { | ||
for (const request of this._pendingRequests.values()) { |
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.
why not forEach?
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 try to avoid forEach
because it's error prone when dealing with promise. I could use it here but I prefer to stick to the same construct everywhere
# [6.2.0](https://github.com/kuzzleio/sdk-javascript/releases/tag/6.2.0) (2019-07-31) #### Bug fixes - [ [#428](#428) ] Properly handle boolean flags in HTTP querystrings ([scottinet](https://github.com/scottinet)) - [ [#427](#427) ] Solve promise+event+memory leaks when the network fails ([scottinet](https://github.com/scottinet)) - [ [#424](#424) ] Prevent pending request leak when disconnect the SDK ([Aschen](https://github.com/Aschen)) - [ [#422](#422) ] Fix bug when decoding JWT in browser ([Aschen](https://github.com/Aschen)) - [ [#420](#420) ] Fix http protocol unresolved promise on connection error ([Aschen](https://github.com/Aschen)) #### New features - [ [#419](#419) ] Add bulk:write and bulk:mWrite ([Aschen](https://github.com/Aschen)) #### Enhancements - [ [#421](#421) ] Get api routes from server:publicApi ([Aschen](https://github.com/Aschen)) - [ [#423](#423) ] Emit queryError event on malformed request ([Aschen](https://github.com/Aschen)) - [ [#417](#417) ] Security controller documentation ([benoitvidis](https://github.com/benoitvidis)) ---
What does this PR do?
When a request is made to Kuzzle, we setup a once listener to handle the response. If a disconnection occur (manual with
disconnect()
or not), the listener are never freed.This PR save the pending requests in a
Map
and when a disconnection occur, adiscarded
event is triggered for each requests and then the map is cleared.Fix #356
Other changes