@nxtedition/deepstream.io-client-js 28.1.12 → 28.1.15
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 +30 -40
package/package.json
CHANGED
|
@@ -269,7 +269,7 @@ class RecordHandler {
|
|
|
269
269
|
let onAbort
|
|
270
270
|
|
|
271
271
|
const signal = opts?.signal
|
|
272
|
-
const timeout = opts?.timeout
|
|
272
|
+
const timeout = opts?.timeout || 2 * 60e3
|
|
273
273
|
|
|
274
274
|
const signalPromise = signal
|
|
275
275
|
? new Promise((resolve, reject) => {
|
|
@@ -278,31 +278,27 @@ class RecordHandler {
|
|
|
278
278
|
}
|
|
279
279
|
signal.addEventListener('abort', onAbort)
|
|
280
280
|
})
|
|
281
|
-
:
|
|
281
|
+
: Promise.resolve()
|
|
282
282
|
signalPromise?.catch(() => {})
|
|
283
283
|
|
|
284
284
|
try {
|
|
285
285
|
if (this._patching.size) {
|
|
286
286
|
let patchingTimeout
|
|
287
287
|
const patching = [...this._patching.values()]
|
|
288
|
+
|
|
288
289
|
await Promise.race([
|
|
289
290
|
Promise.all(
|
|
290
291
|
patching.map((callbacks) => new Promise((resolve) => callbacks.push(resolve))),
|
|
291
292
|
),
|
|
292
293
|
new Promise((resolve) => {
|
|
293
|
-
patchingTimeout = timers.setTimeout(
|
|
294
|
-
(
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
)
|
|
302
|
-
resolve(null)
|
|
303
|
-
},
|
|
304
|
-
timeout ?? 2 * 60e3,
|
|
305
|
-
)
|
|
294
|
+
patchingTimeout = timers.setTimeout(() => {
|
|
295
|
+
this._client._$onError(
|
|
296
|
+
C.TOPIC.RECORD,
|
|
297
|
+
C.EVENT.TIMEOUT,
|
|
298
|
+
new Error('sync patching timeout'),
|
|
299
|
+
)
|
|
300
|
+
resolve(null)
|
|
301
|
+
}, timeout)
|
|
306
302
|
}),
|
|
307
303
|
signalPromise,
|
|
308
304
|
]).finally(() => {
|
|
@@ -313,24 +309,20 @@ class RecordHandler {
|
|
|
313
309
|
if (this._updating.size) {
|
|
314
310
|
let updatingTimeout
|
|
315
311
|
const updating = [...this._updating.values()]
|
|
312
|
+
|
|
316
313
|
await Promise.race([
|
|
317
314
|
Promise.all(
|
|
318
315
|
updating.map((callbacks) => new Promise((resolve) => callbacks.push(resolve))),
|
|
319
316
|
),
|
|
320
317
|
new Promise((resolve) => {
|
|
321
|
-
updatingTimeout = timers.setTimeout(
|
|
322
|
-
(
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
)
|
|
330
|
-
resolve(null)
|
|
331
|
-
},
|
|
332
|
-
timeout ?? 2 * 60e3,
|
|
333
|
-
)
|
|
318
|
+
updatingTimeout = timers.setTimeout(() => {
|
|
319
|
+
this._client._$onError(
|
|
320
|
+
C.TOPIC.RECORD,
|
|
321
|
+
C.EVENT.TIMEOUT,
|
|
322
|
+
new Error('sync updating timeout'),
|
|
323
|
+
)
|
|
324
|
+
resolve(null)
|
|
325
|
+
}, timeout)
|
|
334
326
|
}),
|
|
335
327
|
signalPromise,
|
|
336
328
|
]).finally(() => {
|
|
@@ -340,23 +332,21 @@ class RecordHandler {
|
|
|
340
332
|
|
|
341
333
|
let serverTimeout
|
|
342
334
|
const token = xuid()
|
|
335
|
+
|
|
343
336
|
return await Promise.race([
|
|
344
|
-
|
|
337
|
+
new Promise((resolve) => {
|
|
345
338
|
this._syncEmitter.once(token, resolve)
|
|
346
339
|
this._connection.sendMsg(C.TOPIC.RECORD, C.ACTIONS.SYNC, [token])
|
|
347
340
|
}),
|
|
348
341
|
new Promise((resolve) => {
|
|
349
|
-
serverTimeout = timers.setTimeout(
|
|
350
|
-
(
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
},
|
|
358
|
-
timeout ?? 2 * 60e3,
|
|
359
|
-
)
|
|
342
|
+
serverTimeout = timers.setTimeout(() => {
|
|
343
|
+
this._client._$onError(
|
|
344
|
+
C.TOPIC.RECORD,
|
|
345
|
+
C.EVENT.TIMEOUT,
|
|
346
|
+
new Error('sync server timeout'),
|
|
347
|
+
)
|
|
348
|
+
resolve(null)
|
|
349
|
+
}, timeout)
|
|
360
350
|
}),
|
|
361
351
|
signalPromise,
|
|
362
352
|
]).finally(() => {
|