@nxtedition/deepstream.io-client-js 23.4.24 → 23.4.26

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": "23.4.24",
3
+ "version": "23.4.26",
4
4
  "description": "the javascript client for deepstream.io",
5
5
  "homepage": "http://deepstream.io",
6
6
  "bugs": {
@@ -303,7 +303,7 @@ class RecordHandler {
303
303
  return this._observe(
304
304
  {
305
305
  state: C.RECORD_STATE.SERVER,
306
- timeout: 2 * 60e3,
306
+ timeout: 10 * 60e3,
307
307
  dataOnly: true,
308
308
  },
309
309
  ...args
@@ -438,15 +438,13 @@ class RecordHandler {
438
438
  onUpdate(record)
439
439
  }
440
440
 
441
- const abort = () => {
442
- o.error(new utils.AbortError())
443
- }
441
+ const abort = signal ? () => o.error(new utils.AbortError()) : null
444
442
 
445
- signal?.addEventListener('abort', abort)
443
+ utils.addAbortListener(signal, abort)
446
444
 
447
445
  return () => {
448
446
  record.unsubscribe(onUpdate).unref()
449
- signal?.removeEventListener('abort', abort)
447
+ utils.removeAbortListener(signal, abort)
450
448
  }
451
449
  })
452
450
  }
@@ -127,3 +127,45 @@ module.exports.AbortError = class AbortError extends Error {
127
127
  }
128
128
 
129
129
  module.exports.schedule = isNode ? setImmediate : window.requestIdleCallback
130
+
131
+ const abortSignals = new WeakMap()
132
+ const onAbort = function () {
133
+ const handlers = abortSignals.get(this)
134
+ if (handlers) {
135
+ for (const handler of handlers) {
136
+ handler()
137
+ }
138
+ }
139
+ }
140
+
141
+ module.exports.addAbortListener = function addAbortListener(signal, handler) {
142
+ if (!signal) {
143
+ return
144
+ }
145
+
146
+ let handlers = abortSignals.get(signal)
147
+ if (!handlers) {
148
+ handlers = []
149
+ abortSignals.set(signal, handlers)
150
+ signal.addEventListener('abort', onAbort)
151
+ }
152
+ handlers.push(handler)
153
+ }
154
+
155
+ module.exports.removeAbortListener = function removeAbortListener(signal, handler) {
156
+ if (!signal) {
157
+ return
158
+ }
159
+
160
+ const handlers = abortSignals.get(signal)
161
+ if (handlers) {
162
+ const index = handlers.indexOf(handler)
163
+ if (index !== -1) {
164
+ handlers.splice(index, 1)
165
+ if (handlers.length === 0) {
166
+ abortSignals.delete(signal)
167
+ signal.removeEventListener('abort', onAbort)
168
+ }
169
+ }
170
+ }
171
+ }