@nxtedition/deepstream.io-client-js 24.0.8 → 24.0.10

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": "@nxtedition/deepstream.io-client-js",
3
- "version": "24.0.8",
3
+ "version": "24.0.10",
4
4
  "description": "the javascript client for deepstream.io",
5
5
  "homepage": "http://deepstream.io",
6
6
  "bugs": {
package/src/client.js CHANGED
@@ -91,7 +91,8 @@ Client.prototype._$onMessage = function (message) {
91
91
  }
92
92
 
93
93
  Client.prototype._$onError = function (topic, event, msgOrError, data) {
94
- const error = msgOrError && msgOrError.message ? msgOrError : new Error(msgOrError)
94
+ const error =
95
+ msgOrError && msgOrError.message ? msgOrError : new Error(msgOrError || 'unknown error')
95
96
  error.topic = topic
96
97
  error.event = event
97
98
  error.data = data
@@ -2,7 +2,7 @@ module.exports = {
2
2
  reconnectIntervalIncrement: 1e3,
3
3
  maxReconnectInterval: 6e3,
4
4
  maxReconnectAttempts: Infinity,
5
- maxPacketSize: 512 * 1024,
5
+ maxPacketSize: 1024 * 1024,
6
6
  batchSize: 4096,
7
7
  schedule: null,
8
8
  logger: null,
@@ -158,7 +158,15 @@ class RecordHandler {
158
158
  }
159
159
 
160
160
  get stats() {
161
- return this._stats
161
+ let subscriptions = 0
162
+ for (const listener of this._listeners.values()) {
163
+ subscriptions += listener.subscriptions ?? 0
164
+ }
165
+
166
+ return {
167
+ ...this._stats,
168
+ subscriptions,
169
+ }
162
170
  }
163
171
 
164
172
  /**
@@ -9,7 +9,7 @@ class Listener {
9
9
  this._handler = handler
10
10
  this._client = this._handler._client
11
11
  this._connection = this._handler._connection
12
- this._providers = new Map()
12
+ this._subscriptions = new Map()
13
13
  this._recursive = recursive
14
14
  this._stringify = stringify || JSON.stringify
15
15
 
@@ -20,6 +20,12 @@ class Listener {
20
20
  return this._client.getConnectionState() === C.CONNECTION_STATE.OPEN
21
21
  }
22
22
 
23
+ get stats() {
24
+ return {
25
+ subscriptions: this._subscriptions.size,
26
+ }
27
+ }
28
+
23
29
  _$destroy() {
24
30
  this._reset()
25
31
 
@@ -42,7 +48,7 @@ class Listener {
42
48
  const name = message.data[1]
43
49
 
44
50
  if (message.action === C.ACTIONS.SUBSCRIPTION_FOR_PATTERN_FOUND) {
45
- if (this._providers.has(name)) {
51
+ if (this._subscriptions.has(name)) {
46
52
  this._error(name, 'invalid add: listener exists')
47
53
  return
48
54
  }
@@ -175,9 +181,9 @@ class Listener {
175
181
 
176
182
  provider.start()
177
183
 
178
- this._providers.set(provider.name, provider)
184
+ this._subscriptions.set(provider.name, provider)
179
185
  } else if (message.action === C.ACTIONS.LISTEN_ACCEPT) {
180
- const provider = this._providers.get(name)
186
+ const provider = this._subscriptions.get(name)
181
187
  if (!provider?.value$) {
182
188
  return
183
189
  }
@@ -189,13 +195,13 @@ class Listener {
189
195
  provider.valueSubscription = provider.value$.subscribe(provider.observer)
190
196
  }
191
197
  } else if (message.action === C.ACTIONS.SUBSCRIPTION_FOR_PATTERN_REMOVED) {
192
- const provider = this._providers.get(name)
198
+ const provider = this._subscriptions.get(name)
193
199
 
194
200
  if (!provider) {
195
201
  this._error(name, 'invalid remove: listener missing')
196
202
  } else {
197
203
  provider.stop()
198
- this._providers.delete(provider.name)
204
+ this._subscriptions.delete(provider.name)
199
205
  }
200
206
  } else {
201
207
  return false
@@ -216,10 +222,10 @@ class Listener {
216
222
  }
217
223
 
218
224
  _reset() {
219
- for (const provider of this._providers.values()) {
225
+ for (const provider of this._subscriptions.values()) {
220
226
  provider.stop()
221
227
  }
222
- this._providers.clear()
228
+ this._subscriptions.clear()
223
229
  }
224
230
  }
225
231
 
@@ -43,6 +43,12 @@ class Listener {
43
43
  return this._client.getConnectionState() === C.CONNECTION_STATE.OPEN
44
44
  }
45
45
 
46
+ get stats() {
47
+ return {
48
+ subscriptions: this._subscriptions.size,
49
+ }
50
+ }
51
+
46
52
  _$destroy() {
47
53
  this._reset()
48
54