@nxtedition/deepstream.io-client-js 24.1.18 → 24.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.js +32 -16
package/package.json
CHANGED
package/src/record/record.js
CHANGED
|
@@ -203,12 +203,42 @@ class Record {
|
|
|
203
203
|
|
|
204
204
|
let timeoutHandle
|
|
205
205
|
|
|
206
|
+
const onDone = (err, val) => {
|
|
207
|
+
if (err) {
|
|
208
|
+
reject(err)
|
|
209
|
+
} else {
|
|
210
|
+
resolve(val)
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
this.unref()
|
|
214
|
+
this.unsubscribe(onUpdate)
|
|
215
|
+
|
|
216
|
+
if (timeoutHandle) {
|
|
217
|
+
timers.clearTimeout(timeoutHandle)
|
|
218
|
+
timeoutHandle = null
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
signal?.removeEventListener('abort', onAbort)
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
const onUpdate = () => {
|
|
225
|
+
if (this._state >= state) {
|
|
226
|
+
onDone(null, null)
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
const onAbort = signal
|
|
231
|
+
? () => {
|
|
232
|
+
onDone(signal.reason ?? new utils.AbortError())
|
|
233
|
+
}
|
|
234
|
+
: null
|
|
235
|
+
|
|
206
236
|
if (timeout > 0) {
|
|
207
237
|
timeoutHandle = timers.setTimeout(() => {
|
|
208
238
|
const expected = C.RECORD_STATE_NAME[state]
|
|
209
239
|
const current = C.RECORD_STATE_NAME[this._state]
|
|
210
240
|
|
|
211
|
-
|
|
241
|
+
onDone(
|
|
212
242
|
Object.assign(new Error(`timeout ${this.name} [${current}<${expected}]`), {
|
|
213
243
|
code: 'ETIMEDOUT',
|
|
214
244
|
})
|
|
@@ -216,21 +246,7 @@ class Record {
|
|
|
216
246
|
}, timeout)
|
|
217
247
|
}
|
|
218
248
|
|
|
219
|
-
|
|
220
|
-
if (this._state < state) {
|
|
221
|
-
return
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
this.unref()
|
|
225
|
-
this.unsubscribe(onUpdate)
|
|
226
|
-
|
|
227
|
-
if (timeoutHandle) {
|
|
228
|
-
timers.clearTimeout(timeoutHandle)
|
|
229
|
-
timeoutHandle = null
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
resolve(null)
|
|
233
|
-
}
|
|
249
|
+
signal?.addEventListener('abort', onAbort)
|
|
234
250
|
|
|
235
251
|
this.ref()
|
|
236
252
|
this.subscribe(onUpdate)
|