@nxtedition/deepstream.io-client-js 28.1.17 → 28.1.20
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 +1 -1
- package/src/record/record-handler.js +41 -3
package/package.json
CHANGED
|
@@ -10,6 +10,8 @@ import * as utils from '../utils/utils.js'
|
|
|
10
10
|
import xuid from 'xuid'
|
|
11
11
|
import * as timers from '../utils/timers.js'
|
|
12
12
|
|
|
13
|
+
function noop() {}
|
|
14
|
+
|
|
13
15
|
const kEmpty = Symbol('kEmpty')
|
|
14
16
|
|
|
15
17
|
function onUpdate(record, subscription) {
|
|
@@ -100,7 +102,7 @@ class RecordHandler {
|
|
|
100
102
|
this._pruning = new Set()
|
|
101
103
|
this._patching = new Map()
|
|
102
104
|
this._updating = new Map()
|
|
103
|
-
this._putting = new
|
|
105
|
+
this._putting = new Map()
|
|
104
106
|
|
|
105
107
|
this._connected = 0
|
|
106
108
|
this._stats = {
|
|
@@ -280,6 +282,42 @@ class RecordHandler {
|
|
|
280
282
|
})
|
|
281
283
|
: null
|
|
282
284
|
|
|
285
|
+
signalPromise?.catch(noop)
|
|
286
|
+
|
|
287
|
+
if (this._putting.size) {
|
|
288
|
+
const promises = []
|
|
289
|
+
|
|
290
|
+
{
|
|
291
|
+
const puttingPromises = []
|
|
292
|
+
for (const callbacks of this._putting.values()) {
|
|
293
|
+
puttingPromises.push(new Promise((resolve) => callbacks.push(resolve)))
|
|
294
|
+
}
|
|
295
|
+
promises.push(puttingPromises)
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
if (timeout) {
|
|
299
|
+
promises.push(
|
|
300
|
+
new Promise((resolve) => {
|
|
301
|
+
const patchingTimeout = timers.setTimeout(() => {
|
|
302
|
+
this._client._$onError(
|
|
303
|
+
C.TOPIC.RECORD,
|
|
304
|
+
C.EVENT.TIMEOUT,
|
|
305
|
+
new Error('sync putting timeout'),
|
|
306
|
+
)
|
|
307
|
+
resolve(null)
|
|
308
|
+
}, timeout)
|
|
309
|
+
disposers.push(() => timers.clearTimeout(patchingTimeout))
|
|
310
|
+
}),
|
|
311
|
+
)
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
if (signalPromise) {
|
|
315
|
+
promises.push(signalPromise)
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
await Promise.race(promises)
|
|
319
|
+
}
|
|
320
|
+
|
|
283
321
|
if (this._patching.size) {
|
|
284
322
|
const promises = []
|
|
285
323
|
|
|
@@ -425,7 +463,7 @@ class RecordHandler {
|
|
|
425
463
|
const update = [name, version, jsonPath.stringify(data)]
|
|
426
464
|
this._connection.sendMsg(C.TOPIC.RECORD, C.ACTIONS.PUT, update)
|
|
427
465
|
|
|
428
|
-
this._putting.
|
|
466
|
+
this._putting.set(update, [])
|
|
429
467
|
this._sync((update) => {
|
|
430
468
|
this._putting.delete(update)
|
|
431
469
|
}, update)
|
|
@@ -690,7 +728,7 @@ class RecordHandler {
|
|
|
690
728
|
this._connection.sendMsg(C.TOPIC.RECORD, C.ACTIONS.SYNC, [token])
|
|
691
729
|
}
|
|
692
730
|
|
|
693
|
-
for (const update of this._putting) {
|
|
731
|
+
for (const update of this._putting.keys()) {
|
|
694
732
|
this._connection.sendMsg(C.TOPIC.RECORD, C.ACTIONS.PUT, update)
|
|
695
733
|
}
|
|
696
734
|
} else {
|