@dxos/network-manager 0.3.9-main.73167ec → 0.3.9-main.7501ea3
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-LA2ACGLR.mjs → chunk-S2JHWVGQ.mjs} +299 -82
- package/dist/lib/browser/chunk-S2JHWVGQ.mjs.map +7 -0
- 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/{chunk-QWUG7JSH.cjs → chunk-3SCPMSHV.cjs} +301 -74
- package/dist/lib/node/chunk-3SCPMSHV.cjs.map +7 -0
- package/dist/lib/node/{chunk-XE5JOIGD.cjs → chunk-DMWORJG3.cjs} +13 -4
- package/dist/lib/node/chunk-DMWORJG3.cjs.map +7 -0
- package/dist/lib/node/{datachannel-53JZPGFA.cjs → datachannel-ABYQKZRC.cjs} +9 -9
- package/dist/lib/node/{datachannel-53JZPGFA.cjs.map → datachannel-ABYQKZRC.cjs.map} +2 -2
- package/dist/lib/node/index.cjs +32 -32
- package/dist/lib/node/index.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +19 -19
- package/dist/types/src/connection-log.d.ts.map +1 -1
- package/dist/types/src/swarm/connection.d.ts +4 -1
- package/dist/types/src/swarm/connection.d.ts.map +1 -1
- package/dist/types/src/transport/datachannel/rtc-peer-connection.d.ts +7 -0
- package/dist/types/src/transport/datachannel/rtc-peer-connection.d.ts.map +1 -1
- package/dist/types/src/transport/libdatachannel-transport.d.ts +3 -1
- package/dist/types/src/transport/libdatachannel-transport.d.ts.map +1 -1
- package/dist/types/src/transport/memory-transport.d.ts +3 -1
- package/dist/types/src/transport/memory-transport.d.ts.map +1 -1
- package/dist/types/src/transport/simplepeer-transport-proxy.d.ts +3 -1
- package/dist/types/src/transport/simplepeer-transport-proxy.d.ts.map +1 -1
- package/dist/types/src/transport/simplepeer-transport-service.d.ts +3 -1
- package/dist/types/src/transport/simplepeer-transport-service.d.ts.map +1 -1
- package/dist/types/src/transport/simplepeer-transport.d.ts +4 -1
- package/dist/types/src/transport/simplepeer-transport.d.ts.map +1 -1
- package/dist/types/src/transport/tcp-transport.browser.d.ts +3 -1
- package/dist/types/src/transport/tcp-transport.browser.d.ts.map +1 -1
- package/dist/types/src/transport/tcp-transport.d.ts +3 -1
- package/dist/types/src/transport/tcp-transport.d.ts.map +1 -1
- package/dist/types/src/transport/transport.d.ts +17 -0
- package/dist/types/src/transport/transport.d.ts.map +1 -1
- package/dist/types/src/wire-protocol.d.ts +1 -1
- package/dist/types/src/wire-protocol.d.ts.map +1 -1
- package/package.json +17 -17
- package/src/connection-log.ts +14 -1
- package/src/swarm/connection.ts +40 -6
- package/src/transport/datachannel/rtc-peer-connection.ts +13 -1
- package/src/transport/libdatachannel-transport.ts +44 -4
- package/src/transport/memory-transport.ts +14 -1
- package/src/transport/simplepeer-transport-proxy.ts +9 -1
- package/src/transport/simplepeer-transport-service.ts +14 -0
- package/src/transport/simplepeer-transport.ts +67 -3
- package/src/transport/tcp-transport.browser.ts +9 -1
- package/src/transport/tcp-transport.ts +19 -1
- package/src/transport/transport.ts +19 -0
- package/src/wire-protocol.ts +3 -3
- package/dist/lib/browser/chunk-LA2ACGLR.mjs.map +0 -7
- package/dist/lib/node/chunk-QWUG7JSH.cjs.map +0 -7
- package/dist/lib/node/chunk-XE5JOIGD.cjs.map +0 -7
|
@@ -4,13 +4,13 @@ import {
|
|
|
4
4
|
} from "./chunk-YERMWDRB.mjs";
|
|
5
5
|
|
|
6
6
|
// packages/core/mesh/network-manager/src/swarm/connection.ts
|
|
7
|
-
import { DeferredTask, Event, sleep, scheduleTask, synchronized } from "@dxos/async";
|
|
7
|
+
import { DeferredTask, Event, sleep, scheduleTask, scheduleTaskInterval, synchronized } from "@dxos/async";
|
|
8
8
|
import { Context, cancelWithContext } from "@dxos/context";
|
|
9
9
|
import { ErrorStream } from "@dxos/debug";
|
|
10
10
|
import { invariant } from "@dxos/invariant";
|
|
11
11
|
import { PublicKey } from "@dxos/keys";
|
|
12
|
-
import { log } from "@dxos/log";
|
|
13
|
-
import { CancelledError, ProtocolError, ConnectionResetError, ConnectivityError, UnknownProtocolError, trace } from "@dxos/protocols";
|
|
12
|
+
import { log, logInfo } from "@dxos/log";
|
|
13
|
+
import { CancelledError, ProtocolError, ConnectionResetError, ConnectivityError, TimeoutError, UnknownProtocolError, trace } from "@dxos/protocols";
|
|
14
14
|
function _ts_decorate(decorators, target, key, desc) {
|
|
15
15
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
16
16
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -24,6 +24,7 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
24
24
|
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/connection.ts";
|
|
25
25
|
var STARTING_SIGNALLING_DELAY = 10;
|
|
26
26
|
var TRANSPORT_CONNECTION_TIMEOUT = 1e4;
|
|
27
|
+
var TRANSPORT_STATS_INTERVAL = 5e3;
|
|
27
28
|
var MAX_SIGNALLING_DELAY = 300;
|
|
28
29
|
var ConnectionState;
|
|
29
30
|
(function(ConnectionState5) {
|
|
@@ -86,6 +87,7 @@ var Connection = class {
|
|
|
86
87
|
this.stateChanged = new Event();
|
|
87
88
|
this.errors = new ErrorStream();
|
|
88
89
|
this._instanceId = PublicKey.random().toHex();
|
|
90
|
+
this.transportStats = new Event();
|
|
89
91
|
this._signalSendTask = new DeferredTask(this._ctx, async () => {
|
|
90
92
|
await this._flushSignalBuffer();
|
|
91
93
|
});
|
|
@@ -98,11 +100,14 @@ var Connection = class {
|
|
|
98
100
|
initiator: this.initiator
|
|
99
101
|
}, {
|
|
100
102
|
F: __dxlog_file,
|
|
101
|
-
L:
|
|
103
|
+
L: 134,
|
|
102
104
|
S: this,
|
|
103
105
|
C: (f, a) => f(...a)
|
|
104
106
|
});
|
|
105
107
|
}
|
|
108
|
+
get sessionIdString() {
|
|
109
|
+
return this.sessionId.truncate();
|
|
110
|
+
}
|
|
106
111
|
get state() {
|
|
107
112
|
return this._state;
|
|
108
113
|
}
|
|
@@ -118,7 +123,7 @@ var Connection = class {
|
|
|
118
123
|
async openConnection() {
|
|
119
124
|
invariant(this._state === ConnectionState.INITIAL, "Invalid state.", {
|
|
120
125
|
F: __dxlog_file,
|
|
121
|
-
L:
|
|
126
|
+
L: 164,
|
|
122
127
|
S: this,
|
|
123
128
|
A: [
|
|
124
129
|
"this._state === ConnectionState.INITIAL",
|
|
@@ -129,7 +134,7 @@ var Connection = class {
|
|
|
129
134
|
id: this._instanceId
|
|
130
135
|
}), {
|
|
131
136
|
F: __dxlog_file,
|
|
132
|
-
L:
|
|
137
|
+
L: 165,
|
|
133
138
|
S: this,
|
|
134
139
|
C: (f, a) => f(...a)
|
|
135
140
|
});
|
|
@@ -141,35 +146,35 @@ var Connection = class {
|
|
|
141
146
|
initiator: this.initiator
|
|
142
147
|
}, {
|
|
143
148
|
F: __dxlog_file,
|
|
144
|
-
L:
|
|
149
|
+
L: 166,
|
|
145
150
|
S: this,
|
|
146
151
|
C: (f, a) => f(...a)
|
|
147
152
|
});
|
|
148
153
|
this._changeState(ConnectionState.CONNECTING);
|
|
149
|
-
this._protocol.open().catch((err) => {
|
|
154
|
+
this._protocol.open(this.sessionId).catch((err) => {
|
|
150
155
|
this.errors.raise(err);
|
|
151
156
|
});
|
|
152
157
|
this._protocol.stream.on("close", () => {
|
|
153
158
|
log("protocol stream closed", void 0, {
|
|
154
159
|
F: __dxlog_file,
|
|
155
|
-
L:
|
|
160
|
+
L: 183,
|
|
156
161
|
S: this,
|
|
157
162
|
C: (f, a) => f(...a)
|
|
158
163
|
});
|
|
159
164
|
this.close(new ProtocolError("protocol stream closed")).catch((err) => this.errors.raise(err));
|
|
160
165
|
});
|
|
161
166
|
scheduleTask(this.connectedTimeoutContext, async () => {
|
|
162
|
-
log.info(
|
|
167
|
+
log.info(`timeout waiting ${TRANSPORT_CONNECTION_TIMEOUT / 1e3}s for transport to connect, aborting`, void 0, {
|
|
163
168
|
F: __dxlog_file,
|
|
164
|
-
L:
|
|
169
|
+
L: 190,
|
|
165
170
|
S: this,
|
|
166
171
|
C: (f, a) => f(...a)
|
|
167
172
|
});
|
|
168
|
-
await this.abort().catch((err) => this.errors.raise(err));
|
|
173
|
+
await this.abort(new TimeoutError(`${TRANSPORT_CONNECTION_TIMEOUT / 1e3}s for transport to connect`)).catch((err) => this.errors.raise(err));
|
|
169
174
|
}, TRANSPORT_CONNECTION_TIMEOUT);
|
|
170
175
|
invariant(!this._transport, void 0, {
|
|
171
176
|
F: __dxlog_file,
|
|
172
|
-
L:
|
|
177
|
+
L: 198,
|
|
173
178
|
S: this,
|
|
174
179
|
A: [
|
|
175
180
|
"!this._transport",
|
|
@@ -179,18 +184,20 @@ var Connection = class {
|
|
|
179
184
|
this._transport = this._transportFactory.createTransport({
|
|
180
185
|
initiator: this.initiator,
|
|
181
186
|
stream: this._protocol.stream,
|
|
182
|
-
sendSignal: async (signal) => this._sendSignal(signal)
|
|
187
|
+
sendSignal: async (signal) => this._sendSignal(signal),
|
|
188
|
+
sessionId: this.sessionId
|
|
183
189
|
});
|
|
184
190
|
this._transport.connected.once(async () => {
|
|
185
191
|
this._changeState(ConnectionState.CONNECTED);
|
|
186
192
|
await this.connectedTimeoutContext.dispose();
|
|
187
193
|
this._callbacks?.onConnected?.();
|
|
194
|
+
scheduleTaskInterval(this._ctx, async () => this._emitTransportStats(), TRANSPORT_STATS_INTERVAL);
|
|
188
195
|
});
|
|
189
196
|
this._transport.closed.once(() => {
|
|
190
197
|
this._transport = void 0;
|
|
191
198
|
log("abort triggered by transport close", void 0, {
|
|
192
199
|
F: __dxlog_file,
|
|
193
|
-
L:
|
|
200
|
+
L: 216,
|
|
194
201
|
S: this,
|
|
195
202
|
C: (f, a) => f(...a)
|
|
196
203
|
});
|
|
@@ -201,7 +208,7 @@ var Connection = class {
|
|
|
201
208
|
err
|
|
202
209
|
}, {
|
|
203
210
|
F: __dxlog_file,
|
|
204
|
-
L:
|
|
211
|
+
L: 221,
|
|
205
212
|
S: this,
|
|
206
213
|
C: (f, a) => f(...a)
|
|
207
214
|
});
|
|
@@ -211,7 +218,7 @@ var Connection = class {
|
|
|
211
218
|
if (err instanceof ConnectionResetError) {
|
|
212
219
|
log.info("aborting due to transport ConnectionResetError", void 0, {
|
|
213
220
|
F: __dxlog_file,
|
|
214
|
-
L:
|
|
221
|
+
L: 228,
|
|
215
222
|
S: this,
|
|
216
223
|
C: (f, a) => f(...a)
|
|
217
224
|
});
|
|
@@ -219,7 +226,7 @@ var Connection = class {
|
|
|
219
226
|
} else if (err instanceof ConnectivityError) {
|
|
220
227
|
log.info("aborting due to transport ConnectivityError", void 0, {
|
|
221
228
|
F: __dxlog_file,
|
|
222
|
-
L:
|
|
229
|
+
L: 231,
|
|
223
230
|
S: this,
|
|
224
231
|
C: (f, a) => f(...a)
|
|
225
232
|
});
|
|
@@ -229,7 +236,7 @@ var Connection = class {
|
|
|
229
236
|
err
|
|
230
237
|
}, {
|
|
231
238
|
F: __dxlog_file,
|
|
232
|
-
L:
|
|
239
|
+
L: 234,
|
|
233
240
|
S: this,
|
|
234
241
|
C: (f, a) => f(...a)
|
|
235
242
|
});
|
|
@@ -247,7 +254,7 @@ var Connection = class {
|
|
|
247
254
|
id: this._instanceId
|
|
248
255
|
}), {
|
|
249
256
|
F: __dxlog_file,
|
|
250
|
-
L:
|
|
257
|
+
L: 250,
|
|
251
258
|
S: this,
|
|
252
259
|
C: (f, a) => f(...a)
|
|
253
260
|
});
|
|
@@ -257,14 +264,14 @@ var Connection = class {
|
|
|
257
264
|
err
|
|
258
265
|
}, {
|
|
259
266
|
F: __dxlog_file,
|
|
260
|
-
L:
|
|
267
|
+
L: 257,
|
|
261
268
|
S: this,
|
|
262
269
|
C: (f, a) => f(...a)
|
|
263
270
|
});
|
|
264
271
|
if (this._state === ConnectionState.CLOSED || this._state === ConnectionState.ABORTED) {
|
|
265
272
|
log(`abort ignored: already ${this._state}`, this.closeReason, {
|
|
266
273
|
F: __dxlog_file,
|
|
267
|
-
L:
|
|
274
|
+
L: 259,
|
|
268
275
|
S: this,
|
|
269
276
|
C: (f, a) => f(...a)
|
|
270
277
|
});
|
|
@@ -279,7 +286,7 @@ var Connection = class {
|
|
|
279
286
|
try {
|
|
280
287
|
log("aborting protocol... ", void 0, {
|
|
281
288
|
F: __dxlog_file,
|
|
282
|
-
L:
|
|
289
|
+
L: 273,
|
|
283
290
|
S: this,
|
|
284
291
|
C: (f, a) => f(...a)
|
|
285
292
|
});
|
|
@@ -287,7 +294,7 @@ var Connection = class {
|
|
|
287
294
|
} catch (err2) {
|
|
288
295
|
log.catch(err2, void 0, {
|
|
289
296
|
F: __dxlog_file,
|
|
290
|
-
L:
|
|
297
|
+
L: 276,
|
|
291
298
|
S: this,
|
|
292
299
|
C: (f, a) => f(...a)
|
|
293
300
|
});
|
|
@@ -297,7 +304,7 @@ var Connection = class {
|
|
|
297
304
|
} catch (err2) {
|
|
298
305
|
log.catch(err2, void 0, {
|
|
299
306
|
F: __dxlog_file,
|
|
300
|
-
L:
|
|
307
|
+
L: 283,
|
|
301
308
|
S: this,
|
|
302
309
|
C: (f, a) => f(...a)
|
|
303
310
|
});
|
|
@@ -307,7 +314,7 @@ var Connection = class {
|
|
|
307
314
|
} catch (err2) {
|
|
308
315
|
log.catch(err2, void 0, {
|
|
309
316
|
F: __dxlog_file,
|
|
310
|
-
L:
|
|
317
|
+
L: 289,
|
|
311
318
|
S: this,
|
|
312
319
|
C: (f, a) => f(...a)
|
|
313
320
|
});
|
|
@@ -331,7 +338,7 @@ var Connection = class {
|
|
|
331
338
|
peerId: this.ownId
|
|
332
339
|
}, {
|
|
333
340
|
F: __dxlog_file,
|
|
334
|
-
L:
|
|
341
|
+
L: 314,
|
|
335
342
|
S: this,
|
|
336
343
|
C: (f, a) => f(...a)
|
|
337
344
|
});
|
|
@@ -341,7 +348,7 @@ var Connection = class {
|
|
|
341
348
|
} catch (err2) {
|
|
342
349
|
log.catch(err2, void 0, {
|
|
343
350
|
F: __dxlog_file,
|
|
344
|
-
L:
|
|
351
|
+
L: 321,
|
|
345
352
|
S: this,
|
|
346
353
|
C: (f, a) => f(...a)
|
|
347
354
|
});
|
|
@@ -351,7 +358,34 @@ var Connection = class {
|
|
|
351
358
|
} catch (err2) {
|
|
352
359
|
log.catch(err2, void 0, {
|
|
353
360
|
F: __dxlog_file,
|
|
354
|
-
L:
|
|
361
|
+
L: 328,
|
|
362
|
+
S: this,
|
|
363
|
+
C: (f, a) => f(...a)
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
} else {
|
|
367
|
+
log.info(`graceful close requested when we were in ${lastState} state? aborting`, void 0, {
|
|
368
|
+
F: __dxlog_file,
|
|
369
|
+
L: 331,
|
|
370
|
+
S: this,
|
|
371
|
+
C: (f, a) => f(...a)
|
|
372
|
+
});
|
|
373
|
+
try {
|
|
374
|
+
await this._protocol.abort();
|
|
375
|
+
} catch (err2) {
|
|
376
|
+
log.catch(err2, void 0, {
|
|
377
|
+
F: __dxlog_file,
|
|
378
|
+
L: 335,
|
|
379
|
+
S: this,
|
|
380
|
+
C: (f, a) => f(...a)
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
try {
|
|
384
|
+
await this._transport?.destroy();
|
|
385
|
+
} catch (err2) {
|
|
386
|
+
log.catch(err2, void 0, {
|
|
387
|
+
F: __dxlog_file,
|
|
388
|
+
L: 340,
|
|
355
389
|
S: this,
|
|
356
390
|
C: (f, a) => f(...a)
|
|
357
391
|
});
|
|
@@ -361,7 +395,7 @@ var Connection = class {
|
|
|
361
395
|
peerId: this.ownId
|
|
362
396
|
}, {
|
|
363
397
|
F: __dxlog_file,
|
|
364
|
-
L:
|
|
398
|
+
L: 344,
|
|
365
399
|
S: this,
|
|
366
400
|
C: (f, a) => f(...a)
|
|
367
401
|
});
|
|
@@ -404,7 +438,7 @@ var Connection = class {
|
|
|
404
438
|
err
|
|
405
439
|
}, {
|
|
406
440
|
F: __dxlog_file,
|
|
407
|
-
L:
|
|
441
|
+
L: 382,
|
|
408
442
|
S: this,
|
|
409
443
|
C: (f, a) => f(...a)
|
|
410
444
|
});
|
|
@@ -417,7 +451,7 @@ var Connection = class {
|
|
|
417
451
|
async signal(msg) {
|
|
418
452
|
invariant(msg.sessionId, void 0, {
|
|
419
453
|
F: __dxlog_file,
|
|
420
|
-
L:
|
|
454
|
+
L: 391,
|
|
421
455
|
S: this,
|
|
422
456
|
A: [
|
|
423
457
|
"msg.sessionId",
|
|
@@ -427,7 +461,7 @@ var Connection = class {
|
|
|
427
461
|
if (!msg.sessionId.equals(this.sessionId)) {
|
|
428
462
|
log("dropping signal for incorrect session id", void 0, {
|
|
429
463
|
F: __dxlog_file,
|
|
430
|
-
L:
|
|
464
|
+
L: 393,
|
|
431
465
|
S: this,
|
|
432
466
|
C: (f, a) => f(...a)
|
|
433
467
|
});
|
|
@@ -435,7 +469,7 @@ var Connection = class {
|
|
|
435
469
|
}
|
|
436
470
|
invariant(msg.data.signal || msg.data.signalBatch, void 0, {
|
|
437
471
|
F: __dxlog_file,
|
|
438
|
-
L:
|
|
472
|
+
L: 396,
|
|
439
473
|
S: this,
|
|
440
474
|
A: [
|
|
441
475
|
"msg.data.signal || msg.data.signalBatch",
|
|
@@ -444,7 +478,7 @@ var Connection = class {
|
|
|
444
478
|
});
|
|
445
479
|
invariant(msg.author?.equals(this.remoteId), void 0, {
|
|
446
480
|
F: __dxlog_file,
|
|
447
|
-
L:
|
|
481
|
+
L: 397,
|
|
448
482
|
S: this,
|
|
449
483
|
A: [
|
|
450
484
|
"msg.author?.equals(this.remoteId)",
|
|
@@ -453,7 +487,7 @@ var Connection = class {
|
|
|
453
487
|
});
|
|
454
488
|
invariant(msg.recipient?.equals(this.ownId), void 0, {
|
|
455
489
|
F: __dxlog_file,
|
|
456
|
-
L:
|
|
490
|
+
L: 398,
|
|
457
491
|
S: this,
|
|
458
492
|
A: [
|
|
459
493
|
"msg.recipient?.equals(this.ownId)",
|
|
@@ -477,7 +511,7 @@ var Connection = class {
|
|
|
477
511
|
msg: msg.data
|
|
478
512
|
}, {
|
|
479
513
|
F: __dxlog_file,
|
|
480
|
-
L:
|
|
514
|
+
L: 407,
|
|
481
515
|
S: this,
|
|
482
516
|
C: (f, a) => f(...a)
|
|
483
517
|
});
|
|
@@ -485,7 +519,7 @@ var Connection = class {
|
|
|
485
519
|
} else {
|
|
486
520
|
invariant(this._transport, "Connection not ready to accept signals.", {
|
|
487
521
|
F: __dxlog_file,
|
|
488
|
-
L:
|
|
522
|
+
L: 410,
|
|
489
523
|
S: this,
|
|
490
524
|
A: [
|
|
491
525
|
"this._transport",
|
|
@@ -498,7 +532,7 @@ var Connection = class {
|
|
|
498
532
|
msg: msg.data
|
|
499
533
|
}, {
|
|
500
534
|
F: __dxlog_file,
|
|
501
|
-
L:
|
|
535
|
+
L: 411,
|
|
502
536
|
S: this,
|
|
503
537
|
C: (f, a) => f(...a)
|
|
504
538
|
});
|
|
@@ -516,13 +550,13 @@ var Connection = class {
|
|
|
516
550
|
peerId: this.ownId
|
|
517
551
|
}, {
|
|
518
552
|
F: __dxlog_file,
|
|
519
|
-
L:
|
|
553
|
+
L: 422,
|
|
520
554
|
S: this,
|
|
521
555
|
C: (f, a) => f(...a)
|
|
522
556
|
});
|
|
523
557
|
invariant(state !== this._state, "Already in this state.", {
|
|
524
558
|
F: __dxlog_file,
|
|
525
|
-
L:
|
|
559
|
+
L: 423,
|
|
526
560
|
S: this,
|
|
527
561
|
A: [
|
|
528
562
|
"state !== this._state",
|
|
@@ -532,7 +566,16 @@ var Connection = class {
|
|
|
532
566
|
this._state = state;
|
|
533
567
|
this.stateChanged.emit(state);
|
|
534
568
|
}
|
|
569
|
+
async _emitTransportStats() {
|
|
570
|
+
const stats = await this.transport?.getStats();
|
|
571
|
+
if (stats) {
|
|
572
|
+
this.transportStats.emit(stats);
|
|
573
|
+
}
|
|
574
|
+
}
|
|
535
575
|
};
|
|
576
|
+
_ts_decorate([
|
|
577
|
+
logInfo
|
|
578
|
+
], Connection.prototype, "sessionIdString", null);
|
|
536
579
|
_ts_decorate([
|
|
537
580
|
synchronized
|
|
538
581
|
], Connection.prototype, "abort", null);
|
|
@@ -545,7 +588,7 @@ import { Context as Context2 } from "@dxos/context";
|
|
|
545
588
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
546
589
|
import { PublicKey as PublicKey2 } from "@dxos/keys";
|
|
547
590
|
import { log as log2 } from "@dxos/log";
|
|
548
|
-
import { schema, TimeoutError } from "@dxos/protocols";
|
|
591
|
+
import { schema, TimeoutError as TimeoutError2 } from "@dxos/protocols";
|
|
549
592
|
import { ComplexMap } from "@dxos/util";
|
|
550
593
|
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/signal/swarm-messenger.ts";
|
|
551
594
|
var SwarmMessage = schema.getCodecForType("dxos.mesh.swarm.SwarmMessage");
|
|
@@ -730,7 +773,7 @@ var SwarmMessenger = class {
|
|
|
730
773
|
}
|
|
731
774
|
});
|
|
732
775
|
} catch (err) {
|
|
733
|
-
if (err instanceof
|
|
776
|
+
if (err instanceof TimeoutError2) {
|
|
734
777
|
log2.info("timeout sending answer to offer", {
|
|
735
778
|
err
|
|
736
779
|
}, {
|
|
@@ -789,7 +832,7 @@ import { Context as Context4 } from "@dxos/context";
|
|
|
789
832
|
import { ErrorStream as ErrorStream2 } from "@dxos/debug";
|
|
790
833
|
import { invariant as invariant4 } from "@dxos/invariant";
|
|
791
834
|
import { PublicKey as PublicKey4 } from "@dxos/keys";
|
|
792
|
-
import { log as log4, logInfo } from "@dxos/log";
|
|
835
|
+
import { log as log4, logInfo as logInfo2 } from "@dxos/log";
|
|
793
836
|
import { trace as trace2 } from "@dxos/protocols";
|
|
794
837
|
import { ComplexMap as ComplexMap2, isNotNullOrUndefined } from "@dxos/util";
|
|
795
838
|
|
|
@@ -1753,13 +1796,13 @@ var Swarm = class {
|
|
|
1753
1796
|
}
|
|
1754
1797
|
};
|
|
1755
1798
|
_ts_decorate3([
|
|
1756
|
-
|
|
1799
|
+
logInfo2
|
|
1757
1800
|
], Swarm.prototype, "_instanceId", void 0);
|
|
1758
1801
|
_ts_decorate3([
|
|
1759
|
-
|
|
1802
|
+
logInfo2
|
|
1760
1803
|
], Swarm.prototype, "ownPeerId", null);
|
|
1761
1804
|
_ts_decorate3([
|
|
1762
|
-
|
|
1805
|
+
logInfo2
|
|
1763
1806
|
], Swarm.prototype, "topic", null);
|
|
1764
1807
|
_ts_decorate3([
|
|
1765
1808
|
synchronized3
|
|
@@ -1976,7 +2019,7 @@ var ConnectionLog = class {
|
|
|
1976
2019
|
};
|
|
1977
2020
|
info.connections.push(connectionInfo);
|
|
1978
2021
|
this.update.emit();
|
|
1979
|
-
connection.stateChanged.on((state) => {
|
|
2022
|
+
connection.stateChanged.on(async (state) => {
|
|
1980
2023
|
connectionInfo.state = state;
|
|
1981
2024
|
connectionInfo.closeReason = connection.closeReason;
|
|
1982
2025
|
connectionInfo.lastUpdate = /* @__PURE__ */ new Date();
|
|
@@ -1984,6 +2027,10 @@ var ConnectionLog = class {
|
|
|
1984
2027
|
type: EventType.CONNECTION_STATE_CHANGED,
|
|
1985
2028
|
newState: state
|
|
1986
2029
|
});
|
|
2030
|
+
if (state === ConnectionState.CONNECTED) {
|
|
2031
|
+
const details = await connection.transport?.getDetails();
|
|
2032
|
+
connectionInfo.transportDetails = details;
|
|
2033
|
+
}
|
|
1987
2034
|
this.update.emit();
|
|
1988
2035
|
});
|
|
1989
2036
|
connection.protocol?.stats?.on((stats) => {
|
|
@@ -1993,6 +2040,12 @@ var ConnectionLog = class {
|
|
|
1993
2040
|
connectionInfo.lastUpdate = /* @__PURE__ */ new Date();
|
|
1994
2041
|
this.update.emit();
|
|
1995
2042
|
});
|
|
2043
|
+
connection.transportStats?.on((stats) => {
|
|
2044
|
+
connectionInfo.transportBytesSent = stats.bytesSent;
|
|
2045
|
+
connectionInfo.transportBytesReceived = stats.bytesReceived;
|
|
2046
|
+
connectionInfo.transportPacketsSent = stats.packetsSent;
|
|
2047
|
+
connectionInfo.transportPacketsReceived = stats.packetsReceived;
|
|
2048
|
+
});
|
|
1996
2049
|
gcSwarm(info);
|
|
1997
2050
|
});
|
|
1998
2051
|
}
|
|
@@ -2503,7 +2556,7 @@ import { Event as Event7, Trigger } from "@dxos/async";
|
|
|
2503
2556
|
import { ErrorStream as ErrorStream3 } from "@dxos/debug";
|
|
2504
2557
|
import { invariant as invariant10 } from "@dxos/invariant";
|
|
2505
2558
|
import { PublicKey as PublicKey9 } from "@dxos/keys";
|
|
2506
|
-
import { log as log10, logInfo as
|
|
2559
|
+
import { log as log10, logInfo as logInfo3 } from "@dxos/log";
|
|
2507
2560
|
import { ComplexMap as ComplexMap7 } from "@dxos/util";
|
|
2508
2561
|
function _ts_decorate4(decorators, target, key, desc) {
|
|
2509
2562
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -2678,12 +2731,23 @@ var MemoryTransport = class _MemoryTransport {
|
|
|
2678
2731
|
this._remote.wake(remoteId);
|
|
2679
2732
|
}
|
|
2680
2733
|
}
|
|
2734
|
+
async getDetails() {
|
|
2735
|
+
return this._instanceId.toHex();
|
|
2736
|
+
}
|
|
2737
|
+
async getStats() {
|
|
2738
|
+
return {
|
|
2739
|
+
bytesSent: 0,
|
|
2740
|
+
bytesReceived: 0,
|
|
2741
|
+
packetsSent: 0,
|
|
2742
|
+
packetsReceived: 0
|
|
2743
|
+
};
|
|
2744
|
+
}
|
|
2681
2745
|
};
|
|
2682
2746
|
_ts_decorate4([
|
|
2683
|
-
|
|
2747
|
+
logInfo3
|
|
2684
2748
|
], MemoryTransport.prototype, "_instanceId", void 0);
|
|
2685
2749
|
_ts_decorate4([
|
|
2686
|
-
|
|
2750
|
+
logInfo3
|
|
2687
2751
|
], MemoryTransport.prototype, "_remoteInstanceId", void 0);
|
|
2688
2752
|
|
|
2689
2753
|
// packages/core/mesh/network-manager/src/transport/transport.ts
|
|
@@ -2781,12 +2845,20 @@ var SimplePeerTransport = class {
|
|
|
2781
2845
|
if (err.errorDetail === "sctp-failure") {
|
|
2782
2846
|
this.errors.raise(new ConnectionResetError2("sctp-failure from RTCError", err));
|
|
2783
2847
|
} else {
|
|
2848
|
+
log11.info("unknown RTCError", {
|
|
2849
|
+
err
|
|
2850
|
+
}, {
|
|
2851
|
+
F: __dxlog_file12,
|
|
2852
|
+
L: 74,
|
|
2853
|
+
S: this,
|
|
2854
|
+
C: (f, a) => f(...a)
|
|
2855
|
+
});
|
|
2784
2856
|
this.errors.raise(new UnknownProtocolError2("unknown RTCError", err));
|
|
2785
2857
|
}
|
|
2786
2858
|
} else if ("code" in err) {
|
|
2787
2859
|
log11.info("simple-peer error", err, {
|
|
2788
2860
|
F: __dxlog_file12,
|
|
2789
|
-
L:
|
|
2861
|
+
L: 79,
|
|
2790
2862
|
S: this,
|
|
2791
2863
|
C: (f, a) => f(...a)
|
|
2792
2864
|
});
|
|
@@ -2794,10 +2866,12 @@ var SimplePeerTransport = class {
|
|
|
2794
2866
|
case "ERR_WEBRTC_SUPPORT":
|
|
2795
2867
|
this.errors.raise(new ProtocolError2("WebRTC not supported", err));
|
|
2796
2868
|
break;
|
|
2869
|
+
case "ERR_SIGNALING":
|
|
2870
|
+
this.errors.raise(new ConnectivityError2("signaling failure", err));
|
|
2871
|
+
break;
|
|
2797
2872
|
case "ERR_ICE_CONNECTION_FAILURE":
|
|
2798
2873
|
case "ERR_DATA_CHANNEL":
|
|
2799
2874
|
case "ERR_CONNECTION_FAILURE":
|
|
2800
|
-
case "ERR_SIGNALING":
|
|
2801
2875
|
this.errors.raise(new ConnectivityError2("unknown communication failure", err));
|
|
2802
2876
|
break;
|
|
2803
2877
|
case "ERR_CREATE_OFFER":
|
|
@@ -2814,7 +2888,7 @@ var SimplePeerTransport = class {
|
|
|
2814
2888
|
} else {
|
|
2815
2889
|
log11.info("unknown peer connection error", err, {
|
|
2816
2890
|
F: __dxlog_file12,
|
|
2817
|
-
L:
|
|
2891
|
+
L: 105,
|
|
2818
2892
|
S: this,
|
|
2819
2893
|
C: (f, a) => f(...a)
|
|
2820
2894
|
});
|
|
@@ -2825,10 +2899,10 @@ var SimplePeerTransport = class {
|
|
|
2825
2899
|
this._peer._pc.getStats().then((stats) => {
|
|
2826
2900
|
log11.info("report after webrtc error", {
|
|
2827
2901
|
config: this.params.webrtcConfig,
|
|
2828
|
-
stats
|
|
2902
|
+
stats: Object.fromEntries(stats.entries())
|
|
2829
2903
|
}, {
|
|
2830
2904
|
F: __dxlog_file12,
|
|
2831
|
-
L:
|
|
2905
|
+
L: 113,
|
|
2832
2906
|
S: this,
|
|
2833
2907
|
C: (f, a) => f(...a)
|
|
2834
2908
|
});
|
|
@@ -2837,7 +2911,7 @@ var SimplePeerTransport = class {
|
|
|
2837
2911
|
} catch (err2) {
|
|
2838
2912
|
log11.catch(err2, void 0, {
|
|
2839
2913
|
F: __dxlog_file12,
|
|
2840
|
-
L:
|
|
2914
|
+
L: 120,
|
|
2841
2915
|
S: this,
|
|
2842
2916
|
C: (f, a) => f(...a)
|
|
2843
2917
|
});
|
|
@@ -2848,15 +2922,68 @@ var SimplePeerTransport = class {
|
|
|
2848
2922
|
id: this._instanceId
|
|
2849
2923
|
}), {
|
|
2850
2924
|
F: __dxlog_file12,
|
|
2851
|
-
L:
|
|
2925
|
+
L: 126,
|
|
2852
2926
|
S: this,
|
|
2853
2927
|
C: (f, a) => f(...a)
|
|
2854
2928
|
});
|
|
2855
2929
|
}
|
|
2930
|
+
async getStats() {
|
|
2931
|
+
const stats = await this._getStats();
|
|
2932
|
+
if (!stats) {
|
|
2933
|
+
return {
|
|
2934
|
+
bytesSent: 0,
|
|
2935
|
+
bytesReceived: 0,
|
|
2936
|
+
packetsSent: 0,
|
|
2937
|
+
packetsReceived: 0,
|
|
2938
|
+
rawStats: {}
|
|
2939
|
+
};
|
|
2940
|
+
}
|
|
2941
|
+
return {
|
|
2942
|
+
bytesSent: stats.transport.bytesSent,
|
|
2943
|
+
bytesReceived: stats.transport.bytesReceived,
|
|
2944
|
+
packetsSent: stats.transport.messagesSent,
|
|
2945
|
+
packetsReceived: stats.transport.messagesReceived,
|
|
2946
|
+
rawStats: stats.raw
|
|
2947
|
+
};
|
|
2948
|
+
}
|
|
2949
|
+
async _getStats() {
|
|
2950
|
+
if (typeof this._peer?._pc?.getStats !== "function") {
|
|
2951
|
+
return null;
|
|
2952
|
+
}
|
|
2953
|
+
return await this._peer._pc.getStats().then((stats) => {
|
|
2954
|
+
const statsEntries = Array.from(stats.entries());
|
|
2955
|
+
const transport = statsEntries.filter((s) => s[1].type === "transport")[0][1];
|
|
2956
|
+
const candidatePair = statsEntries.filter((s) => s[0] === transport.selectedCandidatePairId);
|
|
2957
|
+
let selectedCandidatePair;
|
|
2958
|
+
let remoteCandidate;
|
|
2959
|
+
if (candidatePair.length > 0) {
|
|
2960
|
+
selectedCandidatePair = candidatePair[0][1];
|
|
2961
|
+
remoteCandidate = statsEntries.filter((s) => s[0] === selectedCandidatePair.remoteCandidateId)[0][1];
|
|
2962
|
+
}
|
|
2963
|
+
return {
|
|
2964
|
+
datachannel: statsEntries.filter((s) => s[1].type === "data-channel")[0][1],
|
|
2965
|
+
transport,
|
|
2966
|
+
selectedCandidatePair,
|
|
2967
|
+
remoteCandidate,
|
|
2968
|
+
raw: Object.fromEntries(stats.entries())
|
|
2969
|
+
};
|
|
2970
|
+
});
|
|
2971
|
+
}
|
|
2972
|
+
async getDetails() {
|
|
2973
|
+
const stats = await this._getStats();
|
|
2974
|
+
const rc = stats?.remoteCandidate;
|
|
2975
|
+
if (!rc) {
|
|
2976
|
+
return "unavailable";
|
|
2977
|
+
}
|
|
2978
|
+
if (rc.relay) {
|
|
2979
|
+
return `${rc.ip}:${rc.port}/${rc.protocol} relay for XXX ${rc.candidateType}`;
|
|
2980
|
+
}
|
|
2981
|
+
return `${rc.ip}:${rc.port}/${rc.protocol} ${rc.candidateType}`;
|
|
2982
|
+
}
|
|
2856
2983
|
async destroy() {
|
|
2857
2984
|
log11("closing...", void 0, {
|
|
2858
2985
|
F: __dxlog_file12,
|
|
2859
|
-
L:
|
|
2986
|
+
L: 189,
|
|
2860
2987
|
S: this,
|
|
2861
2988
|
C: (f, a) => f(...a)
|
|
2862
2989
|
});
|
|
@@ -2866,10 +2993,11 @@ var SimplePeerTransport = class {
|
|
|
2866
2993
|
this._closed = true;
|
|
2867
2994
|
this._disconnectStreams();
|
|
2868
2995
|
this._peer.destroy();
|
|
2996
|
+
this._closed = true;
|
|
2869
2997
|
this.closed.emit();
|
|
2870
2998
|
log11("closed", void 0, {
|
|
2871
2999
|
F: __dxlog_file12,
|
|
2872
|
-
L:
|
|
3000
|
+
L: 198,
|
|
2873
3001
|
S: this,
|
|
2874
3002
|
C: (f, a) => f(...a)
|
|
2875
3003
|
});
|
|
@@ -2984,7 +3112,7 @@ var SimplePeerTransportService = class {
|
|
|
2984
3112
|
async sendSignal({ proxyId, signal }) {
|
|
2985
3113
|
invariant12(this.transports.has(proxyId), void 0, {
|
|
2986
3114
|
F: __dxlog_file13,
|
|
2987
|
-
L:
|
|
3115
|
+
L: 116,
|
|
2988
3116
|
S: this,
|
|
2989
3117
|
A: [
|
|
2990
3118
|
"this.transports.has(proxyId)",
|
|
@@ -2993,18 +3121,46 @@ var SimplePeerTransportService = class {
|
|
|
2993
3121
|
});
|
|
2994
3122
|
await this.transports.get(proxyId).transport.signal(signal);
|
|
2995
3123
|
}
|
|
3124
|
+
async getDetails({ proxyId }) {
|
|
3125
|
+
invariant12(this.transports.has(proxyId), void 0, {
|
|
3126
|
+
F: __dxlog_file13,
|
|
3127
|
+
L: 121,
|
|
3128
|
+
S: this,
|
|
3129
|
+
A: [
|
|
3130
|
+
"this.transports.has(proxyId)",
|
|
3131
|
+
""
|
|
3132
|
+
]
|
|
3133
|
+
});
|
|
3134
|
+
return {
|
|
3135
|
+
details: await this.transports.get(proxyId).transport.getDetails()
|
|
3136
|
+
};
|
|
3137
|
+
}
|
|
3138
|
+
async getStats({ proxyId }) {
|
|
3139
|
+
invariant12(this.transports.has(proxyId), void 0, {
|
|
3140
|
+
F: __dxlog_file13,
|
|
3141
|
+
L: 126,
|
|
3142
|
+
S: this,
|
|
3143
|
+
A: [
|
|
3144
|
+
"this.transports.has(proxyId)",
|
|
3145
|
+
""
|
|
3146
|
+
]
|
|
3147
|
+
});
|
|
3148
|
+
return {
|
|
3149
|
+
stats: await this.transports.get(proxyId).transport.getStats()
|
|
3150
|
+
};
|
|
3151
|
+
}
|
|
2996
3152
|
async sendData({ proxyId, payload }) {
|
|
2997
3153
|
if (this.transports.get(proxyId)?.state !== "OPEN") {
|
|
2998
3154
|
log12.debug("transport is closed", void 0, {
|
|
2999
3155
|
F: __dxlog_file13,
|
|
3000
|
-
L:
|
|
3156
|
+
L: 132,
|
|
3001
3157
|
S: this,
|
|
3002
3158
|
C: (f, a) => f(...a)
|
|
3003
3159
|
});
|
|
3004
3160
|
}
|
|
3005
3161
|
invariant12(this.transports.has(proxyId), void 0, {
|
|
3006
3162
|
F: __dxlog_file13,
|
|
3007
|
-
L:
|
|
3163
|
+
L: 134,
|
|
3008
3164
|
S: this,
|
|
3009
3165
|
A: [
|
|
3010
3166
|
"this.transports.has(proxyId)",
|
|
@@ -3027,7 +3183,7 @@ var SimplePeerTransportService = class {
|
|
|
3027
3183
|
}
|
|
3028
3184
|
log12("Closed.", void 0, {
|
|
3029
3185
|
F: __dxlog_file13,
|
|
3030
|
-
L:
|
|
3186
|
+
L: 150,
|
|
3031
3187
|
S: this,
|
|
3032
3188
|
C: (f, a) => f(...a)
|
|
3033
3189
|
});
|
|
@@ -3042,7 +3198,7 @@ import { ErrorStream as ErrorStream5 } from "@dxos/debug";
|
|
|
3042
3198
|
import { invariant as invariant13 } from "@dxos/invariant";
|
|
3043
3199
|
import { PublicKey as PublicKey12 } from "@dxos/keys";
|
|
3044
3200
|
import { log as log13 } from "@dxos/log";
|
|
3045
|
-
import { ConnectionResetError as ConnectionResetError3, TimeoutError as
|
|
3201
|
+
import { ConnectionResetError as ConnectionResetError3, TimeoutError as TimeoutError3, ProtocolError as ProtocolError3, ConnectivityError as ConnectivityError3, UnknownProtocolError as UnknownProtocolError3 } from "@dxos/protocols";
|
|
3046
3202
|
import { ConnectionState as ConnectionState4 } from "@dxos/protocols/proto/dxos/mesh/bridge";
|
|
3047
3203
|
import { arrayToBuffer } from "@dxos/util";
|
|
3048
3204
|
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/simplepeer-transport-proxy.ts";
|
|
@@ -3098,9 +3254,9 @@ var SimplePeerTransportProxy = class {
|
|
|
3098
3254
|
}
|
|
3099
3255
|
this._timeoutCount = 0;
|
|
3100
3256
|
}, (err) => {
|
|
3101
|
-
if (err instanceof
|
|
3257
|
+
if (err instanceof TimeoutError3 || err.constructor.name === "TimeoutError") {
|
|
3102
3258
|
if (this._timeoutCount++ > TIMEOUT_THRESHOLD) {
|
|
3103
|
-
throw new
|
|
3259
|
+
throw new TimeoutError3(`too many timeoutes (${this._timeoutCount} > ${TIMEOUT_THRESHOLD}`);
|
|
3104
3260
|
} else {
|
|
3105
3261
|
log13("timeout error, but still invoking callback", void 0, {
|
|
3106
3262
|
F: __dxlog_file14,
|
|
@@ -3166,6 +3322,16 @@ var SimplePeerTransportProxy = class {
|
|
|
3166
3322
|
signal
|
|
3167
3323
|
}).catch((err) => this.errors.raise(decodeError(err)));
|
|
3168
3324
|
}
|
|
3325
|
+
async getDetails() {
|
|
3326
|
+
return (await this._params.bridgeService.getDetails({
|
|
3327
|
+
proxyId: this._proxyId
|
|
3328
|
+
})).details;
|
|
3329
|
+
}
|
|
3330
|
+
async getStats() {
|
|
3331
|
+
return (await this._params.bridgeService.getStats({
|
|
3332
|
+
proxyId: this._proxyId
|
|
3333
|
+
})).stats;
|
|
3334
|
+
}
|
|
3169
3335
|
// TODO(burdon): Move open from constructor.
|
|
3170
3336
|
async destroy() {
|
|
3171
3337
|
await this._ctx.dispose();
|
|
@@ -3180,7 +3346,7 @@ var SimplePeerTransportProxy = class {
|
|
|
3180
3346
|
} catch (err) {
|
|
3181
3347
|
log13.catch(err, void 0, {
|
|
3182
3348
|
F: __dxlog_file14,
|
|
3183
|
-
L:
|
|
3349
|
+
L: 168,
|
|
3184
3350
|
S: this,
|
|
3185
3351
|
C: (f, a) => f(...a)
|
|
3186
3352
|
});
|
|
@@ -3216,7 +3382,7 @@ var SimplePeerTransportProxyFactory = class {
|
|
|
3216
3382
|
createTransport(options) {
|
|
3217
3383
|
invariant13(this._bridgeService, "SimplePeerTransportProxyFactory is not ready to open connections", {
|
|
3218
3384
|
F: __dxlog_file14,
|
|
3219
|
-
L:
|
|
3385
|
+
L: 205,
|
|
3220
3386
|
S: this,
|
|
3221
3387
|
A: [
|
|
3222
3388
|
"this._bridgeService",
|
|
@@ -3237,7 +3403,7 @@ var decodeError = (err) => {
|
|
|
3237
3403
|
if (message.includes("CONNECTION_RESET")) {
|
|
3238
3404
|
return new ConnectionResetError3(message);
|
|
3239
3405
|
} else if (message.includes("TIMEOUT")) {
|
|
3240
|
-
return new
|
|
3406
|
+
return new TimeoutError3(message);
|
|
3241
3407
|
} else if (message.includes("PROTOCOL_ERROR")) {
|
|
3242
3408
|
return new ProtocolError3(message);
|
|
3243
3409
|
} else if (message.includes("CONNECTIVITY_ERROR")) {
|
|
@@ -3417,16 +3583,21 @@ var LibDataChannelTransport = class {
|
|
|
3417
3583
|
const duplex = new Duplex2({
|
|
3418
3584
|
read: () => {
|
|
3419
3585
|
},
|
|
3420
|
-
write: (chunk, encoding, callback) => {
|
|
3586
|
+
write: async (chunk, encoding, callback) => {
|
|
3421
3587
|
if (chunk.length > MAX_MESSAGE_SIZE) {
|
|
3422
3588
|
this.errors.raise(new Error(`message too large: ${chunk.length} > ${MAX_MESSAGE_SIZE}`));
|
|
3423
3589
|
}
|
|
3424
|
-
|
|
3590
|
+
try {
|
|
3591
|
+
dataChannel.send(chunk);
|
|
3592
|
+
} catch (err) {
|
|
3593
|
+
this.errors.raise(err);
|
|
3594
|
+
await this._close();
|
|
3595
|
+
}
|
|
3425
3596
|
if (this._channel.bufferedAmount > MAX_BUFFERED_AMOUNT) {
|
|
3426
3597
|
if (this._writeCallback !== null) {
|
|
3427
3598
|
log14.error("consumer trying to write before we're ready for more data", void 0, {
|
|
3428
3599
|
F: __dxlog_file15,
|
|
3429
|
-
L:
|
|
3600
|
+
L: 143,
|
|
3430
3601
|
S: this,
|
|
3431
3602
|
C: (f, a) => f(...a)
|
|
3432
3603
|
});
|
|
@@ -3451,7 +3622,7 @@ var LibDataChannelTransport = class {
|
|
|
3451
3622
|
err
|
|
3452
3623
|
}, {
|
|
3453
3624
|
F: __dxlog_file15,
|
|
3454
|
-
L:
|
|
3625
|
+
L: 163,
|
|
3455
3626
|
S: this,
|
|
3456
3627
|
C: (f, a) => f(...a)
|
|
3457
3628
|
});
|
|
@@ -3488,7 +3659,7 @@ var LibDataChannelTransport = class {
|
|
|
3488
3659
|
peer
|
|
3489
3660
|
}, {
|
|
3490
3661
|
F: __dxlog_file15,
|
|
3491
|
-
L:
|
|
3662
|
+
L: 198,
|
|
3492
3663
|
S: this,
|
|
3493
3664
|
C: (f, a) => f(...a)
|
|
3494
3665
|
});
|
|
@@ -3516,7 +3687,7 @@ var LibDataChannelTransport = class {
|
|
|
3516
3687
|
err
|
|
3517
3688
|
}, {
|
|
3518
3689
|
F: __dxlog_file15,
|
|
3519
|
-
L:
|
|
3690
|
+
L: 209,
|
|
3520
3691
|
S: this,
|
|
3521
3692
|
C: (f, a) => f(...a)
|
|
3522
3693
|
});
|
|
@@ -3536,7 +3707,7 @@ var LibDataChannelTransport = class {
|
|
|
3536
3707
|
err
|
|
3537
3708
|
}, {
|
|
3538
3709
|
F: __dxlog_file15,
|
|
3539
|
-
L:
|
|
3710
|
+
L: 220,
|
|
3540
3711
|
S: this,
|
|
3541
3712
|
C: (f, a) => f(...a)
|
|
3542
3713
|
});
|
|
@@ -3555,7 +3726,7 @@ var LibDataChannelTransport = class {
|
|
|
3555
3726
|
signal
|
|
3556
3727
|
}, {
|
|
3557
3728
|
F: __dxlog_file15,
|
|
3558
|
-
L:
|
|
3729
|
+
L: 231,
|
|
3559
3730
|
S: this,
|
|
3560
3731
|
C: (f, a) => f(...a)
|
|
3561
3732
|
});
|
|
@@ -3564,10 +3735,50 @@ var LibDataChannelTransport = class {
|
|
|
3564
3735
|
}).catch((err) => {
|
|
3565
3736
|
log14.catch(err, void 0, {
|
|
3566
3737
|
F: __dxlog_file15,
|
|
3567
|
-
L:
|
|
3738
|
+
L: 236,
|
|
3739
|
+
S: this,
|
|
3740
|
+
C: (f, a) => f(...a)
|
|
3741
|
+
});
|
|
3742
|
+
});
|
|
3743
|
+
}
|
|
3744
|
+
async getDetails() {
|
|
3745
|
+
return this._peer.then(async (peer) => {
|
|
3746
|
+
const cp = await peer.getSelectedCandidatePair();
|
|
3747
|
+
if (!cp) {
|
|
3748
|
+
return "unavailable";
|
|
3749
|
+
}
|
|
3750
|
+
return `${cp.remote.address}:${cp.remote.port}/${cp.remote.transportType} ${cp.remote.type}`;
|
|
3751
|
+
}).catch((err) => {
|
|
3752
|
+
log14.catch(err, void 0, {
|
|
3753
|
+
F: __dxlog_file15,
|
|
3754
|
+
L: 250,
|
|
3568
3755
|
S: this,
|
|
3569
3756
|
C: (f, a) => f(...a)
|
|
3570
3757
|
});
|
|
3758
|
+
return "unavailable";
|
|
3759
|
+
});
|
|
3760
|
+
}
|
|
3761
|
+
async getStats() {
|
|
3762
|
+
return this._peer.then((peer) => {
|
|
3763
|
+
return {
|
|
3764
|
+
bytesSent: peer.bytesSent(),
|
|
3765
|
+
bytesReceived: peer.bytesReceived(),
|
|
3766
|
+
packetsSent: 0,
|
|
3767
|
+
packetsReceived: 0
|
|
3768
|
+
};
|
|
3769
|
+
}).catch((err) => {
|
|
3770
|
+
log14.catch(err, void 0, {
|
|
3771
|
+
F: __dxlog_file15,
|
|
3772
|
+
L: 266,
|
|
3773
|
+
S: this,
|
|
3774
|
+
C: (f, a) => f(...a)
|
|
3775
|
+
});
|
|
3776
|
+
return {
|
|
3777
|
+
bytesSent: 0,
|
|
3778
|
+
bytesReceived: 0,
|
|
3779
|
+
packetsSent: 0,
|
|
3780
|
+
packetsReceived: 0
|
|
3781
|
+
};
|
|
3571
3782
|
});
|
|
3572
3783
|
}
|
|
3573
3784
|
// TODO(nf): add classmethod to call node-datachannel.cleanup() when all instances have been destroyed?
|
|
@@ -3606,6 +3817,12 @@ var TcpTransport = class {
|
|
|
3606
3817
|
signal() {
|
|
3607
3818
|
throw new Error("Method not implemented.");
|
|
3608
3819
|
}
|
|
3820
|
+
async getStats() {
|
|
3821
|
+
throw new Error("Method not implemented.");
|
|
3822
|
+
}
|
|
3823
|
+
async getDetails() {
|
|
3824
|
+
throw new Error("Method not implemented.");
|
|
3825
|
+
}
|
|
3609
3826
|
};
|
|
3610
3827
|
|
|
3611
3828
|
// packages/core/mesh/network-manager/src/wire-protocol.ts
|
|
@@ -3615,8 +3832,8 @@ var createTeleportProtocolFactory = (onConnection) => {
|
|
|
3615
3832
|
const teleport = new Teleport(params);
|
|
3616
3833
|
return {
|
|
3617
3834
|
stream: teleport.stream,
|
|
3618
|
-
open: async () => {
|
|
3619
|
-
await teleport.open();
|
|
3835
|
+
open: async (sessionId) => {
|
|
3836
|
+
await teleport.open(sessionId);
|
|
3620
3837
|
await onConnection(teleport);
|
|
3621
3838
|
},
|
|
3622
3839
|
close: async () => {
|
|
@@ -3657,4 +3874,4 @@ export {
|
|
|
3657
3874
|
TcpTransport,
|
|
3658
3875
|
createTeleportProtocolFactory
|
|
3659
3876
|
};
|
|
3660
|
-
//# sourceMappingURL=chunk-
|
|
3877
|
+
//# sourceMappingURL=chunk-S2JHWVGQ.mjs.map
|