@nxtedition/deepstream.io-client-js 24.1.16 → 24.1.17

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": "24.1.16",
3
+ "version": "24.1.17",
4
4
  "description": "the javascript client for deepstream.io",
5
5
  "homepage": "http://deepstream.io",
6
6
  "bugs": {
@@ -175,8 +175,7 @@ class Record {
175
175
  }
176
176
  }
177
177
 
178
- // TODO (fix): timeout + signal
179
- async when(stateOrNil, optionsOrNil) {
178
+ when(stateOrNil, optionsOrNil) {
180
179
  invariant(this._refs > 0, 'missing refs')
181
180
 
182
181
  if (stateOrNil != null && stateOrNil === 'object') {
@@ -188,11 +187,15 @@ class Record {
188
187
  const state = stateOrNil ?? C.RECORD_STATE.SERVER
189
188
  const timeout = optionsOrNil?.timeout ?? 2 * 60e3
190
189
 
190
+ if (signal?.aborted) {
191
+ return Promise.reject(signal.reason || new utils.AbortError())
192
+ }
193
+
191
194
  if (!Number.isFinite(state) || state < 0) {
192
- throw new Error('invalid argument: state')
195
+ return Promise.reject(new Error('invalid argument: state'))
193
196
  }
194
197
 
195
- await new Promise((resolve, reject) => {
198
+ return new Promise((resolve, reject) => {
196
199
  if (this._state >= state) {
197
200
  resolve(null)
198
201
  return
@@ -232,8 +235,6 @@ class Record {
232
235
  this.ref()
233
236
  this.subscribe(onUpdate)
234
237
  })
235
-
236
- signal?.throwIfAborted()
237
238
  }
238
239
 
239
240
  update(...args) {
@@ -264,6 +265,10 @@ class Record {
264
265
  throw new Error('invalid argument: path')
265
266
  }
266
267
 
268
+ if (options?.signal?.aborted) {
269
+ return Promise.reject(options.signal.reason || new utils.AbortError())
270
+ }
271
+
267
272
  this.ref()
268
273
  return this.when(C.RECORD_STATE.SERVER, options)
269
274
  .then(() => {