@nxtedition/deepstream.io-client-js 24.2.0 → 24.2.2
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/message/connection.js +5 -5
- package/src/record/record-handler.js +20 -13
- package/src/record/record.js +1 -1
- package/src/utils/utils.js +5 -1
package/package.json
CHANGED
|
@@ -140,10 +140,10 @@ Connection.prototype.send = function (message) {
|
|
|
140
140
|
if (this._endpoint._socket && !this._corked) {
|
|
141
141
|
this._endpoint._socket.cork()
|
|
142
142
|
this._corked = true
|
|
143
|
-
|
|
143
|
+
setTimeout(() => {
|
|
144
144
|
this._endpoint._socket.uncork()
|
|
145
145
|
this._corked = false
|
|
146
|
-
})
|
|
146
|
+
}, 1)
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
this.emit('send', message)
|
|
@@ -188,7 +188,7 @@ Connection.prototype._onOpen = function () {
|
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
Connection.prototype._onError = function (err) {
|
|
191
|
-
this._recvMessages()
|
|
191
|
+
this._recvMessages({ didTimeout: true, timeRemaining: () => 0 })
|
|
192
192
|
|
|
193
193
|
if (err.error) {
|
|
194
194
|
const { message, error } = err
|
|
@@ -210,7 +210,7 @@ Connection.prototype._onError = function (err) {
|
|
|
210
210
|
}
|
|
211
211
|
|
|
212
212
|
Connection.prototype._onClose = function () {
|
|
213
|
-
this._recvMessages()
|
|
213
|
+
this._recvMessages({ didTimeout: true, timeRemaining: () => 0 })
|
|
214
214
|
|
|
215
215
|
if (this._deliberateClose === true) {
|
|
216
216
|
this._setState(C.CONNECTION_STATE.CLOSED)
|
|
@@ -236,7 +236,7 @@ Connection.prototype._recvMessages = function (deadline) {
|
|
|
236
236
|
for (
|
|
237
237
|
let n = 0;
|
|
238
238
|
// eslint-disable-next-line no-unmodified-loop-condition
|
|
239
|
-
|
|
239
|
+
deadline ? deadline.didTimeout || deadline.timeRemaining() : n < this._batchSize;
|
|
240
240
|
++n
|
|
241
241
|
) {
|
|
242
242
|
const message = this._recvQueue.shift()
|
|
@@ -45,9 +45,12 @@ function onTimeout(subscription) {
|
|
|
45
45
|
const current = C.RECORD_STATE_NAME[subscription.record.state]
|
|
46
46
|
|
|
47
47
|
subscription.subscriber.error(
|
|
48
|
-
Object.assign(
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
Object.assign(
|
|
49
|
+
new Error(`timeout state: ${subscription.record.name} [${current}<${expected}]`),
|
|
50
|
+
{
|
|
51
|
+
code: 'ETIMEDOUT',
|
|
52
|
+
}
|
|
53
|
+
)
|
|
51
54
|
)
|
|
52
55
|
}
|
|
53
56
|
|
|
@@ -68,16 +71,20 @@ function onSyncFast(opaque) {
|
|
|
68
71
|
}
|
|
69
72
|
|
|
70
73
|
function onTimeoutFast(opaque) {
|
|
71
|
-
const { rec, resolve } = opaque
|
|
74
|
+
const { rec, synced, resolve } = opaque
|
|
72
75
|
rec.unsubscribe(onUpdateFast, opaque)
|
|
73
76
|
rec.unref()
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
)
|
|
80
|
-
|
|
77
|
+
|
|
78
|
+
let err
|
|
79
|
+
if (rec.state < opaque.state) {
|
|
80
|
+
err = new Error(`timeout state: ${opaque.rec.name} [${opaque.rec.state}<${opaque.state}]`)
|
|
81
|
+
} else if (!synced) {
|
|
82
|
+
err = new Error(`timeout sync: ${opaque.rec.name} `)
|
|
83
|
+
} else {
|
|
84
|
+
err = new Error('timeout')
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
resolve(Promise.reject(Object.assign(err, { code: 'ETIMEDOUT' })))
|
|
81
88
|
}
|
|
82
89
|
|
|
83
90
|
class RecordHandler {
|
|
@@ -356,7 +363,7 @@ class RecordHandler {
|
|
|
356
363
|
return
|
|
357
364
|
}
|
|
358
365
|
|
|
359
|
-
|
|
366
|
+
setTimeout(() => {
|
|
360
367
|
// Token must be universally unique until deepstream properly separates
|
|
361
368
|
// sync requests from different sockets.
|
|
362
369
|
const token = xuid()
|
|
@@ -367,7 +374,7 @@ class RecordHandler {
|
|
|
367
374
|
}
|
|
368
375
|
})
|
|
369
376
|
this._connection.sendMsg2(C.TOPIC.RECORD, C.ACTIONS.SYNC, token, 'WEAK')
|
|
370
|
-
})
|
|
377
|
+
}, 1)
|
|
371
378
|
}
|
|
372
379
|
|
|
373
380
|
set(name, ...args) {
|
package/src/record/record.js
CHANGED
|
@@ -128,7 +128,7 @@ class Record {
|
|
|
128
128
|
if (!path) {
|
|
129
129
|
return this._data
|
|
130
130
|
} else if (typeof path === 'string' || Array.isArray(path)) {
|
|
131
|
-
return
|
|
131
|
+
return jsonPath.get(this._data, path)
|
|
132
132
|
} else if (typeof path === 'function') {
|
|
133
133
|
return path(this._data)
|
|
134
134
|
} else {
|
package/src/utils/utils.js
CHANGED
|
@@ -126,7 +126,11 @@ module.exports.AbortError = class AbortError extends Error {
|
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
|
|
129
|
+
function defaultSchedule(fn) {
|
|
130
|
+
setTimeout(fn, 0)
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
module.exports.schedule = isNode ? defaultSchedule : window.requestIdleCallback
|
|
130
134
|
|
|
131
135
|
const abortSignals = new WeakMap()
|
|
132
136
|
const onAbort = function () {
|