Skip to content

Conversation

Aschen
Copy link
Contributor

@Aschen Aschen commented Nov 20, 2019

7.0.0 (2019-11-20)

Bug fixes

Enhancements

  • [ #455 ] Do not try to reconnect if the browser is offline (scottinet)

scottinet and others added 4 commits November 7, 2019 16:21
# Description

If `autoReconnect` is true, the SDK tries to reconnect every `reconnectionDelay` milliseconds.

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.
# Description

The `onerror` event handler called in browsers' WebSocket API differ from the one exposed by the `ws` module used in Node.js: the handler in browsers receive a generic `Event` object without any error information, while the ws handler receives a proper error.

Result: `kuzzle.connect().catch(e => console.log(e))` prints something like `Error: [object Event]` in a browser's console.

This PR fixes that issue by detecting the case and sending a generic `Connection error` to the connect promise handler.
This PR fixes the way we pass the refresh option in several routes.
Before that, the option was lost and never passed to ES.
@Aschen Aschen added the release label Nov 20, 2019
@codecov
Copy link

codecov bot commented Nov 20, 2019

Codecov Report

Merging #467 into 7-beta will decrease coverage by 0.03%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           7-beta     #467      +/-   ##
==========================================
- Coverage      96%   95.96%   -0.04%     
==========================================
  Files          33       33              
  Lines        1350     1338      -12     
==========================================
- Hits         1296     1284      -12     
  Misses         54       54
Impacted Files Coverage Δ
src/controllers/index.js 100% <100%> (ø) ⬆️
src/Kuzzle.js 94.46% <100%> (ø) ⬆️
src/controllers/collection.js 100% <100%> (ø) ⬆️
src/controllers/document.js 95.08% <100%> (-0.92%) ⬇️
src/protocols/abstract/realtime.js 100% <100%> (ø) ⬆️
src/protocols/websocket.js 100% <100%> (ø) ⬆️
src/controllers/security/index.js 99.2% <100%> (-0.06%) ⬇️

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 a11c5eb...739b703. Read the comment docs.

@Aschen Aschen changed the base branch from 7-beta to master November 21, 2019 03:27
@Aschen Aschen changed the base branch from master to 7-beta November 21, 2019 03:27
@Aschen Aschen merged commit 411b5b6 into 7-beta Nov 21, 2019
@Aschen Aschen deleted the 7.0.0-proposal branch November 21, 2019 03:27
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.

3 participants