braid-http 1.3.51 → 1.3.52
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 +6 -0
- package/package.json +1 -1
package/braid-http-client.js
CHANGED
|
@@ -916,6 +916,8 @@ async function multiplex_fetch(url, params, mux_params, aborter) {
|
|
|
916
916
|
var requests = new Map()
|
|
917
917
|
var mux_error = null
|
|
918
918
|
var try_deleting = new Set()
|
|
919
|
+
var not_used_timeout = null
|
|
920
|
+
var mux_aborter = new AbortController()
|
|
919
921
|
|
|
920
922
|
function cleanup(e, stay_dead) {
|
|
921
923
|
// the multiplexer stream has died.. let everyone know..
|
|
@@ -952,6 +954,7 @@ async function multiplex_fetch(url, params, mux_params, aborter) {
|
|
|
952
954
|
try {
|
|
953
955
|
if (mux_params?.via === 'POST') throw 'skip multiplex method'
|
|
954
956
|
var r = await braid_fetch(`${origin}/${multiplexer}`, {
|
|
957
|
+
signal: mux_aborter.signal,
|
|
955
958
|
method: 'MULTIPLEX',
|
|
956
959
|
headers: {'Multiplex-Version': multiplex_version},
|
|
957
960
|
retry: true
|
|
@@ -969,6 +972,7 @@ async function multiplex_fetch(url, params, mux_params, aborter) {
|
|
|
969
972
|
try {
|
|
970
973
|
r = await braid_fetch(`${origin}/.well-known/multiplexer/${multiplexer}`,
|
|
971
974
|
{method: 'POST',
|
|
975
|
+
signal: mux_aborter.signal,
|
|
972
976
|
headers: {'Multiplex-Version': multiplex_version},
|
|
973
977
|
retry: true})
|
|
974
978
|
if (r.status === 409) {
|
|
@@ -1048,9 +1052,11 @@ async function multiplex_fetch(url, params, mux_params, aborter) {
|
|
|
1048
1052
|
})
|
|
1049
1053
|
|
|
1050
1054
|
// prepare a function that we'll call to cleanly tear things down
|
|
1055
|
+
clearTimeout(not_used_timeout)
|
|
1051
1056
|
var unset = async e => {
|
|
1052
1057
|
unset = () => {}
|
|
1053
1058
|
requests.delete(request)
|
|
1059
|
+
if (!requests.size) not_used_timeout = setTimeout(() => mux_aborter.abort(), mux_params?.not_used_timeout ?? 1000 * 20)
|
|
1054
1060
|
request_error = e
|
|
1055
1061
|
bytes_available()
|
|
1056
1062
|
await try_deleting_request(request)
|