braid-http 1.3.70 → 1.3.72

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.
@@ -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 && // some errors are unlikely to be fixed by retrying
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..
@@ -340,7 +337,7 @@ async function braid_fetch (url, params = {}) {
340
337
  clearTimeout(timeout)
341
338
  let wait_seconds = 1.2 * heartbeats + 3
342
339
  timeout = setTimeout(() => {
343
- on_error(new Error(`heartbeat seen in ${wait_seconds.toFixed(2)}s`))
340
+ on_error(new Error(`heartbeat not seen in ${wait_seconds.toFixed(2)}s`))
344
341
  }, wait_seconds * 1000)
345
342
  }
346
343
  on_heartbeat()
@@ -367,9 +364,15 @@ async function braid_fetch (url, params = {}) {
367
364
  throw create_error('already aborted', {name: 'AbortError'})
368
365
 
369
366
  // Yay! We got a new version! Tell the callback!
370
- cb_running = true
371
- await cb(result)
372
- cb_running = false
367
+ try {
368
+ await cb(result)
369
+ } catch (e) {
370
+ // This error is happening in the users code,
371
+ // so retrying the connection
372
+ // will probably still fail
373
+ e.dont_retry = true
374
+ throw e
375
+ }
373
376
  } else
374
377
  // This error handling code runs if the connection
375
378
  // closes, or if there is unparseable stuff in the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "braid-http",
3
- "version": "1.3.70",
3
+ "version": "1.3.72",
4
4
  "description": "An implementation of Braid-HTTP for Node.js and Browsers",
5
5
  "scripts": {
6
6
  "test": "node test/server.js"