@pryv/monitor 3.0.2 → 3.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pryv/monitor",
3
- "version": "3.0.2",
3
+ "version": "3.0.3",
4
4
  "description": "Extends `pryv` with event-driven notifications for changes on a Pryv.io account",
5
5
  "keywords": [
6
6
  "Pryv",
@@ -23,7 +23,16 @@ class Socket extends UpdateMethod {
23
23
  this.socket = await this.monitor.connection.socket.open();
24
24
  this.socket.on('eventsChanged', () => { this.monitor.updateEvents(); });
25
25
  this.socket.on('streamsChanged', () => { this.monitor.updateStreams(); });
26
- this.socket.on('error', (error) => { this.monitor.emit(Changes.ERROR, error); });
26
+ this.socket.on('error', (error) => {
27
+ this.monitor.emit(Changes.ERROR, error);
28
+ // If the underlying socket.io-client transport has been torn down
29
+ // (i.e. SocketIO emitted 'error' after reconnect_failed), drop our
30
+ // reference so a future Changes.READY can rebuild instead of
31
+ // short-circuiting on the cached, dead handle.
32
+ if (this.socket && !this.socket._io) {
33
+ this.socket = null;
34
+ }
35
+ });
27
36
  }
28
37
 
29
38
  async stop () {