braid-http 1.3.85 → 1.3.87
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 +8 -5
- package/braid-http-server.js +1 -1
- package/package.json +1 -1
package/braid-http-client.js
CHANGED
|
@@ -230,7 +230,7 @@ async function braid_fetch (url, params = {}) {
|
|
|
230
230
|
() => underlying_aborter.abort()
|
|
231
231
|
)
|
|
232
232
|
|
|
233
|
-
var
|
|
233
|
+
var retry_count = 0
|
|
234
234
|
var res = null
|
|
235
235
|
var subscription_cb = null
|
|
236
236
|
var subscription_error = null
|
|
@@ -272,9 +272,12 @@ async function braid_fetch (url, params = {}) {
|
|
|
272
272
|
|
|
273
273
|
if (retry && !original_signal?.aborted) {
|
|
274
274
|
// retry after some time..
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
275
|
+
var delay_ms = typeof braid_fetch.reconnect_delay_ms === 'function'
|
|
276
|
+
? braid_fetch.reconnect_delay_ms(retry_count)
|
|
277
|
+
: braid_fetch.reconnect_delay_ms ?? Math.min(retry_count + 1, 3) * 1000
|
|
278
|
+
console.log(`retrying in ${delay_ms}ms: ${url} after error: ${e}`)
|
|
279
|
+
setTimeout(connect, delay_ms)
|
|
280
|
+
retry_count++
|
|
278
281
|
} else {
|
|
279
282
|
// if we would have retried except that original_signal?.aborted,
|
|
280
283
|
// then we want to return that as the error..
|
|
@@ -470,7 +473,7 @@ async function braid_fetch (url, params = {}) {
|
|
|
470
473
|
if (subscription_cb && res.ok) start_subscription(subscription_cb, subscription_error)
|
|
471
474
|
|
|
472
475
|
params?.retry?.onRes?.(res)
|
|
473
|
-
|
|
476
|
+
retry_count = 0
|
|
474
477
|
|
|
475
478
|
// parse version if it exists
|
|
476
479
|
var version_header = res.headers.get('version') || res.headers.get('current-version')
|
package/braid-http-server.js
CHANGED
|
@@ -240,7 +240,7 @@ function braidify (req, res, next) {
|
|
|
240
240
|
|
|
241
241
|
// Parse the subscribe header
|
|
242
242
|
var subscribe = req.headers.subscribe
|
|
243
|
-
if (subscribe === 'true')
|
|
243
|
+
if (subscribe === '' || subscribe === 'true')
|
|
244
244
|
subscribe = true
|
|
245
245
|
|
|
246
246
|
// Define convenience variables
|