@dxos/network-manager 0.3.5-main.52b008a → 0.3.5-main.57bfc4f
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/dist/lib/browser/{chunk-6MP4SAMK.mjs → chunk-APBMCUJP.mjs} +57 -15
- package/dist/lib/browser/{chunk-6MP4SAMK.mjs.map → chunk-APBMCUJP.mjs.map} +3 -3
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +1 -1
- package/dist/lib/node/index.cjs +55 -13
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +55 -13
- package/dist/lib/node/testing/index.cjs.map +3 -3
- package/dist/types/src/transport/simplepeer-transport-proxy.d.ts +1 -0
- package/dist/types/src/transport/simplepeer-transport-proxy.d.ts.map +1 -1
- package/package.json +17 -17
- package/src/transport/simplepeer-transport-proxy.ts +43 -17
|
@@ -3026,7 +3026,7 @@ var SimplePeerTransportService = class {
|
|
|
3026
3026
|
|
|
3027
3027
|
// packages/core/mesh/network-manager/src/transport/simplepeer-transport-proxy.ts
|
|
3028
3028
|
import { Writable } from "@dxos/node-std/stream";
|
|
3029
|
-
import { Event as Event9 } from "@dxos/async";
|
|
3029
|
+
import { Event as Event9, scheduleTask as scheduleTask4 } from "@dxos/async";
|
|
3030
3030
|
import { Context as Context6 } from "@dxos/context";
|
|
3031
3031
|
import { ErrorStream as ErrorStream5 } from "@dxos/debug";
|
|
3032
3032
|
import { invariant as invariant13 } from "@dxos/invariant";
|
|
@@ -3036,11 +3036,14 @@ import { ConnectionResetError as ConnectionResetError3, TimeoutError as TimeoutE
|
|
|
3036
3036
|
import { ConnectionState as ConnectionState4 } from "@dxos/protocols/proto/dxos/mesh/bridge";
|
|
3037
3037
|
import { arrayToBuffer } from "@dxos/util";
|
|
3038
3038
|
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/simplepeer-transport-proxy.ts";
|
|
3039
|
+
var RESP_MIN_THRESHOLD = 500;
|
|
3040
|
+
var TIMEOUT_THRESHOLD = 10;
|
|
3039
3041
|
var SimplePeerTransportProxy = class {
|
|
3040
3042
|
constructor(_params) {
|
|
3041
3043
|
this._params = _params;
|
|
3042
3044
|
this._proxyId = PublicKey12.random();
|
|
3043
3045
|
this._ctx = new Context6();
|
|
3046
|
+
this._timeoutCount = 0;
|
|
3044
3047
|
this.closed = new Event9();
|
|
3045
3048
|
this.connected = new Event9();
|
|
3046
3049
|
this.errors = new ErrorStream5();
|
|
@@ -3053,7 +3056,7 @@ var SimplePeerTransportProxy = class {
|
|
|
3053
3056
|
this._serviceStream.subscribe(async (event) => {
|
|
3054
3057
|
log13("SimplePeerTransportProxy: event", event, {
|
|
3055
3058
|
F: __dxlog_file14,
|
|
3056
|
-
L:
|
|
3059
|
+
L: 59,
|
|
3057
3060
|
S: this,
|
|
3058
3061
|
C: (f, a) => f(...a)
|
|
3059
3062
|
});
|
|
@@ -3065,24 +3068,63 @@ var SimplePeerTransportProxy = class {
|
|
|
3065
3068
|
await this._handleSignal(event.signal);
|
|
3066
3069
|
}
|
|
3067
3070
|
});
|
|
3068
|
-
|
|
3071
|
+
const proxyStream = new Writable({
|
|
3069
3072
|
write: (chunk, _, callback) => {
|
|
3073
|
+
const then = performance.now();
|
|
3070
3074
|
this._params.bridgeService.sendData({
|
|
3071
3075
|
proxyId: this._proxyId,
|
|
3072
3076
|
payload: chunk
|
|
3073
|
-
}).then(() =>
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3077
|
+
}).then(() => {
|
|
3078
|
+
if (performance.now() - then > RESP_MIN_THRESHOLD) {
|
|
3079
|
+
log13("slow response, delaying callback", void 0, {
|
|
3080
|
+
F: __dxlog_file14,
|
|
3081
|
+
L: 80,
|
|
3082
|
+
S: this,
|
|
3083
|
+
C: (f, a) => f(...a)
|
|
3084
|
+
});
|
|
3085
|
+
scheduleTask4(this._ctx, () => callback(), RESP_MIN_THRESHOLD);
|
|
3086
|
+
} else {
|
|
3087
|
+
callback();
|
|
3088
|
+
}
|
|
3089
|
+
this._timeoutCount = 0;
|
|
3090
|
+
}, (err) => {
|
|
3091
|
+
if (err instanceof TimeoutError2 || err.constructor.name === "TimeoutError") {
|
|
3092
|
+
if (this._timeoutCount++ > TIMEOUT_THRESHOLD) {
|
|
3093
|
+
throw new TimeoutError2(`too many timeoutes (${this._timeoutCount} > ${TIMEOUT_THRESHOLD}`);
|
|
3094
|
+
} else {
|
|
3095
|
+
log13("timeout error, but still invoking callback", void 0, {
|
|
3096
|
+
F: __dxlog_file14,
|
|
3097
|
+
L: 92,
|
|
3098
|
+
S: this,
|
|
3099
|
+
C: (f, a) => f(...a)
|
|
3100
|
+
});
|
|
3101
|
+
callback();
|
|
3102
|
+
}
|
|
3103
|
+
} else {
|
|
3104
|
+
log13.catch(err, void 0, {
|
|
3105
|
+
F: __dxlog_file14,
|
|
3106
|
+
L: 96,
|
|
3107
|
+
S: this,
|
|
3108
|
+
C: (f, a) => f(...a)
|
|
3109
|
+
});
|
|
3110
|
+
}
|
|
3080
3111
|
});
|
|
3081
3112
|
}
|
|
3082
|
-
})
|
|
3113
|
+
});
|
|
3114
|
+
proxyStream.on("error", (err) => {
|
|
3115
|
+
log13("proxystream error", {
|
|
3116
|
+
err
|
|
3117
|
+
}, {
|
|
3118
|
+
F: __dxlog_file14,
|
|
3119
|
+
L: 104,
|
|
3120
|
+
S: this,
|
|
3121
|
+
C: (f, a) => f(...a)
|
|
3122
|
+
});
|
|
3123
|
+
});
|
|
3124
|
+
this._params.stream.pipe(proxyStream);
|
|
3083
3125
|
}, (error) => log13.catch(error, void 0, {
|
|
3084
3126
|
F: __dxlog_file14,
|
|
3085
|
-
L:
|
|
3127
|
+
L: 109,
|
|
3086
3128
|
S: this,
|
|
3087
3129
|
C: (f, a) => f(...a)
|
|
3088
3130
|
}));
|
|
@@ -3128,7 +3170,7 @@ var SimplePeerTransportProxy = class {
|
|
|
3128
3170
|
} catch (err) {
|
|
3129
3171
|
log13.catch(err, void 0, {
|
|
3130
3172
|
F: __dxlog_file14,
|
|
3131
|
-
L:
|
|
3173
|
+
L: 160,
|
|
3132
3174
|
S: this,
|
|
3133
3175
|
C: (f, a) => f(...a)
|
|
3134
3176
|
});
|
|
@@ -3164,7 +3206,7 @@ var SimplePeerTransportProxyFactory = class {
|
|
|
3164
3206
|
createTransport(options) {
|
|
3165
3207
|
invariant13(this._bridgeService, "SimplePeerTransportProxyFactory is not ready to open connections", {
|
|
3166
3208
|
F: __dxlog_file14,
|
|
3167
|
-
L:
|
|
3209
|
+
L: 197,
|
|
3168
3210
|
S: this,
|
|
3169
3211
|
A: [
|
|
3170
3212
|
"this._bridgeService",
|
|
@@ -3605,4 +3647,4 @@ export {
|
|
|
3605
3647
|
TcpTransport,
|
|
3606
3648
|
createTeleportProtocolFactory
|
|
3607
3649
|
};
|
|
3608
|
-
//# sourceMappingURL=chunk-
|
|
3650
|
+
//# sourceMappingURL=chunk-APBMCUJP.mjs.map
|