-
Notifications
You must be signed in to change notification settings - Fork 17
Do not try to reconnect if the browser is offline #456
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 #456 +/- ##
==========================================
+ Coverage 96.02% 96.03% +0.01%
==========================================
Files 33 33
Lines 1357 1362 +5
==========================================
+ Hits 1303 1308 +5
Misses 54 54
Continue to review full report at Codecov.
|
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 don't understand quite well this PR I think.
I see that you add a hook on the navigator online event to reconnect the SDK but shouldn't we have a hook on the offline event as well?
Co-Authored-By: Adrien Maret <amaret93@gmail.com>
|
@Aschen > About this PR's goal: assuming the SDK is run in a browser, if So we never need to listen to the "offline" event. |
# [6.2.6](https://github.com/kuzzleio/sdk-javascript/releases/tag/6.2.6) (2019-11-05) #### Enhancements - [ [#456](#456) ] Do not try to reconnect if the browser is offline ([scottinet](https://github.com/scottinet)) - [ [#451](#451) ] Remove local checks for arguments ([Aschen](https://github.com/Aschen)) ---
Description
If
autoReconnectis true, the SDK tries to reconnect everyreconnectionDelaymilliseconds.If executed within a browser, the SDK can know if the browser has access to some kind of network: if it's marked as "offline", then there is no point retrying to connect, and this might even be harmful in some situations. For instance, browsers switch to offline if a laptop lid is closed, or if a mobile phone screen is turned off. So continuing to connect is just a useless consumption of battery power.
This PR stops the reconnection loop and instead waits for the browser to switch to "online" again before resuming its reconnection attempts.