braid-http 1.3.71 → 1.3.73
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/braid-http-client.js +13 -9
- package/package.json +1 -1
package/braid-http-client.js
CHANGED
|
@@ -232,7 +232,6 @@ async function braid_fetch (url, params = {}) {
|
|
|
232
232
|
var res = null
|
|
233
233
|
var subscription_cb = null
|
|
234
234
|
var subscription_error = null
|
|
235
|
-
var cb_running = false
|
|
236
235
|
|
|
237
236
|
// Multiplexing book-keeping;
|
|
238
237
|
// basically, if the user tries to make two or more subscriptions to the same origin,
|
|
@@ -267,9 +266,7 @@ async function braid_fetch (url, params = {}) {
|
|
|
267
266
|
// see if we should retry..
|
|
268
267
|
var retry = params.retry && // only try to reconnect if the user has chosen to
|
|
269
268
|
e.name !== "AbortError" && // don't retry if the user has chosen to abort
|
|
270
|
-
!e.dont_retry
|
|
271
|
-
!cb_running // if an error is thrown in the callback,
|
|
272
|
-
// then it may not be good to reconnect, and generate more errors
|
|
269
|
+
!e.dont_retry // some errors are unlikely to be fixed by retrying
|
|
273
270
|
|
|
274
271
|
if (retry && !original_signal?.aborted) {
|
|
275
272
|
// retry after some time..
|
|
@@ -347,8 +344,9 @@ async function braid_fetch (url, params = {}) {
|
|
|
347
344
|
}
|
|
348
345
|
}
|
|
349
346
|
|
|
350
|
-
if (
|
|
351
|
-
throw new Error(
|
|
347
|
+
if (res.status !== 209) {
|
|
348
|
+
throw new Error(`Got unexpected subscription status code: ${res.status}. Expected 209.`)
|
|
349
|
+
}
|
|
352
350
|
|
|
353
351
|
if (res.bodyUsed)
|
|
354
352
|
// TODO: check if this needs a return
|
|
@@ -367,9 +365,15 @@ async function braid_fetch (url, params = {}) {
|
|
|
367
365
|
throw create_error('already aborted', {name: 'AbortError'})
|
|
368
366
|
|
|
369
367
|
// Yay! We got a new version! Tell the callback!
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
368
|
+
try {
|
|
369
|
+
await cb(result)
|
|
370
|
+
} catch (e) {
|
|
371
|
+
// This error is happening in the users code,
|
|
372
|
+
// so retrying the connection
|
|
373
|
+
// will probably still fail
|
|
374
|
+
e.dont_retry = true
|
|
375
|
+
throw e
|
|
376
|
+
}
|
|
373
377
|
} else
|
|
374
378
|
// This error handling code runs if the connection
|
|
375
379
|
// closes, or if there is unparseable stuff in the
|