braid-http 1.3.72 → 1.3.74
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 +7 -2
- package/package.json +1 -1
package/braid-http-client.js
CHANGED
|
@@ -344,8 +344,9 @@ async function braid_fetch (url, params = {}) {
|
|
|
344
344
|
}
|
|
345
345
|
}
|
|
346
346
|
|
|
347
|
-
if (
|
|
348
|
-
throw new Error(
|
|
347
|
+
if (res.status !== 209) {
|
|
348
|
+
throw new Error(`Got unexpected subscription status code: ${res.status}. Expected 209.`)
|
|
349
|
+
}
|
|
349
350
|
|
|
350
351
|
if (res.bodyUsed)
|
|
351
352
|
// TODO: check if this needs a return
|
|
@@ -442,9 +443,13 @@ async function braid_fetch (url, params = {}) {
|
|
|
442
443
|
case 429: // Too Many Requests
|
|
443
444
|
|
|
444
445
|
case 502: // Bad Gateway
|
|
446
|
+
case 503: // Service Unavailable
|
|
445
447
|
case 504: // Gateway Timeout
|
|
446
448
|
give_up = false
|
|
447
449
|
}
|
|
450
|
+
if (res.statusText.match(/Missing Parents/i) ||
|
|
451
|
+
res.headers.get('retry-after') !== null)
|
|
452
|
+
give_up = false
|
|
448
453
|
if (give_up) {
|
|
449
454
|
if (subscription_cb) subscription_error?.(new Error(`giving up because of http status: ${res.status}${(res.status === 401 || res.status === 403) ? ` (access denied)` : ''}`))
|
|
450
455
|
} else if (!res.ok) throw new Error(`status not ok: ${res.status}`)
|