braid-http 1.3.60 → 1.3.61
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 -4
- package/package.json +4 -1
package/braid-http-client.js
CHANGED
|
@@ -949,7 +949,7 @@ async function create_multiplexer(origin, mux_key, params, mux_params, attempt)
|
|
|
949
949
|
if (!try_deleting.has(request)) {
|
|
950
950
|
try_deleting.add(request)
|
|
951
951
|
try {
|
|
952
|
-
var mux_was_done = await promise_done(
|
|
952
|
+
var mux_was_done = await promise_done(mux_created_promise)
|
|
953
953
|
|
|
954
954
|
var r = await braid_fetch(`${origin}/.well-known/multiplexer/${multiplexer}/${request}`, {
|
|
955
955
|
method: 'DELETE',
|
|
@@ -979,7 +979,10 @@ async function create_multiplexer(origin, mux_key, params, mux_params, attempt)
|
|
|
979
979
|
}
|
|
980
980
|
}
|
|
981
981
|
|
|
982
|
-
|
|
982
|
+
// This promise resolves when the create_multiplexer request responds.
|
|
983
|
+
// - its value is undefined if successfully created
|
|
984
|
+
// - its value is false if creation failed
|
|
985
|
+
var mux_created_promise = (async () => {
|
|
983
986
|
// attempt to establish a multiplexed connection
|
|
984
987
|
try {
|
|
985
988
|
if (mux_params?.via === 'POST') throw 'skip multiplex method'
|
|
@@ -1039,7 +1042,7 @@ async function create_multiplexer(origin, mux_key, params, mux_params, attempt)
|
|
|
1039
1042
|
|
|
1040
1043
|
// if we already know the multiplexer is not working,
|
|
1041
1044
|
// then fallback to normal fetch
|
|
1042
|
-
if ((await promise_done(
|
|
1045
|
+
if ((await promise_done(mux_created_promise)) && (await mux_created_promise) === false) {
|
|
1043
1046
|
// if the user is specifically asking for multiplexing,
|
|
1044
1047
|
// throw an error instead
|
|
1045
1048
|
if (params.headers.get('multiplex-through')) throw new Error('multiplexer failed')
|
|
@@ -1105,7 +1108,7 @@ async function create_multiplexer(origin, mux_key, params, mux_params, attempt)
|
|
|
1105
1108
|
|
|
1106
1109
|
// do the underlying fetch
|
|
1107
1110
|
try {
|
|
1108
|
-
var mux_was_done = await promise_done(
|
|
1111
|
+
var mux_was_done = await promise_done(mux_created_promise)
|
|
1109
1112
|
|
|
1110
1113
|
// callback for testing
|
|
1111
1114
|
mux_params?.onFetch?.(url, params)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "braid-http",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.61",
|
|
4
4
|
"description": "An implementation of Braid-HTTP for Node.js and Browsers",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "node test/server.js"
|
|
@@ -29,5 +29,8 @@
|
|
|
29
29
|
"node-fetch": "^2.6.1",
|
|
30
30
|
"parse-headers": "^2.0.3",
|
|
31
31
|
"web-streams-node": "^0.4.0"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"express": "^4.21.2"
|
|
32
35
|
}
|
|
33
36
|
}
|