@dxos/network-manager 0.3.8 → 0.3.9-main.1d6fb54
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-H7XJ7HES.mjs → chunk-4HITD6WI.mjs} +129 -77
- package/dist/lib/browser/chunk-4HITD6WI.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 +3 -3
- package/dist/lib/node/{chunk-RBHZCZH4.cjs → chunk-6AD7QA4X.cjs} +126 -74
- package/dist/lib/node/chunk-6AD7QA4X.cjs.map +7 -0
- package/dist/lib/node/index.cjs +27 -27
- package/dist/lib/node/index.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +20 -20
- package/dist/types/src/connection-log.d.ts.map +1 -1
- package/dist/types/src/swarm/connection.d.ts.map +1 -1
- package/dist/types/src/transport/libdatachannel-transport.d.ts.map +1 -1
- package/dist/types/src/transport/simplepeer-transport.d.ts.map +1 -1
- package/package.json +17 -17
- package/src/connection-log.ts +13 -0
- package/src/swarm/connection.ts +17 -2
- package/src/transport/libdatachannel-transport.ts +7 -3
- package/src/transport/simplepeer-transport.ts +4 -1
- package/dist/lib/browser/chunk-H7XJ7HES.mjs.map +0 -7
- package/dist/lib/node/chunk-RBHZCZH4.cjs.map +0 -7
|
@@ -10,7 +10,7 @@ import { ErrorStream } from "@dxos/debug";
|
|
|
10
10
|
import { invariant } from "@dxos/invariant";
|
|
11
11
|
import { PublicKey } from "@dxos/keys";
|
|
12
12
|
import { log } from "@dxos/log";
|
|
13
|
-
import { CancelledError, ProtocolError, ConnectionResetError, ConnectivityError, UnknownProtocolError, trace } from "@dxos/protocols";
|
|
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")
|
|
@@ -21,7 +21,7 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
21
21
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
22
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
23
|
}
|
|
24
|
-
var __dxlog_file = "/home/
|
|
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
27
|
var MAX_SIGNALLING_DELAY = 300;
|
|
@@ -98,7 +98,7 @@ var Connection = class {
|
|
|
98
98
|
initiator: this.initiator
|
|
99
99
|
}, {
|
|
100
100
|
F: __dxlog_file,
|
|
101
|
-
L:
|
|
101
|
+
L: 130,
|
|
102
102
|
S: this,
|
|
103
103
|
C: (f, a) => f(...a)
|
|
104
104
|
});
|
|
@@ -118,7 +118,7 @@ var Connection = class {
|
|
|
118
118
|
async openConnection() {
|
|
119
119
|
invariant(this._state === ConnectionState.INITIAL, "Invalid state.", {
|
|
120
120
|
F: __dxlog_file,
|
|
121
|
-
L:
|
|
121
|
+
L: 155,
|
|
122
122
|
S: this,
|
|
123
123
|
A: [
|
|
124
124
|
"this._state === ConnectionState.INITIAL",
|
|
@@ -129,7 +129,7 @@ var Connection = class {
|
|
|
129
129
|
id: this._instanceId
|
|
130
130
|
}), {
|
|
131
131
|
F: __dxlog_file,
|
|
132
|
-
L:
|
|
132
|
+
L: 156,
|
|
133
133
|
S: this,
|
|
134
134
|
C: (f, a) => f(...a)
|
|
135
135
|
});
|
|
@@ -141,7 +141,7 @@ var Connection = class {
|
|
|
141
141
|
initiator: this.initiator
|
|
142
142
|
}, {
|
|
143
143
|
F: __dxlog_file,
|
|
144
|
-
L:
|
|
144
|
+
L: 157,
|
|
145
145
|
S: this,
|
|
146
146
|
C: (f, a) => f(...a)
|
|
147
147
|
});
|
|
@@ -152,24 +152,24 @@ var Connection = class {
|
|
|
152
152
|
this._protocol.stream.on("close", () => {
|
|
153
153
|
log("protocol stream closed", void 0, {
|
|
154
154
|
F: __dxlog_file,
|
|
155
|
-
L:
|
|
155
|
+
L: 174,
|
|
156
156
|
S: this,
|
|
157
157
|
C: (f, a) => f(...a)
|
|
158
158
|
});
|
|
159
159
|
this.close(new ProtocolError("protocol stream closed")).catch((err) => this.errors.raise(err));
|
|
160
160
|
});
|
|
161
161
|
scheduleTask(this.connectedTimeoutContext, async () => {
|
|
162
|
-
log.info(
|
|
162
|
+
log.info(`timeout waiting ${TRANSPORT_CONNECTION_TIMEOUT / 1e3}s for transport to connect, aborting`, void 0, {
|
|
163
163
|
F: __dxlog_file,
|
|
164
|
-
L:
|
|
164
|
+
L: 181,
|
|
165
165
|
S: this,
|
|
166
166
|
C: (f, a) => f(...a)
|
|
167
167
|
});
|
|
168
|
-
await this.abort().catch((err) => this.errors.raise(err));
|
|
168
|
+
await this.abort(new TimeoutError(`${TRANSPORT_CONNECTION_TIMEOUT / 1e3}s for transport to connect`)).catch((err) => this.errors.raise(err));
|
|
169
169
|
}, TRANSPORT_CONNECTION_TIMEOUT);
|
|
170
170
|
invariant(!this._transport, void 0, {
|
|
171
171
|
F: __dxlog_file,
|
|
172
|
-
L:
|
|
172
|
+
L: 189,
|
|
173
173
|
S: this,
|
|
174
174
|
A: [
|
|
175
175
|
"!this._transport",
|
|
@@ -190,7 +190,7 @@ var Connection = class {
|
|
|
190
190
|
this._transport = void 0;
|
|
191
191
|
log("abort triggered by transport close", void 0, {
|
|
192
192
|
F: __dxlog_file,
|
|
193
|
-
L:
|
|
193
|
+
L: 204,
|
|
194
194
|
S: this,
|
|
195
195
|
C: (f, a) => f(...a)
|
|
196
196
|
});
|
|
@@ -201,7 +201,7 @@ var Connection = class {
|
|
|
201
201
|
err
|
|
202
202
|
}, {
|
|
203
203
|
F: __dxlog_file,
|
|
204
|
-
L:
|
|
204
|
+
L: 209,
|
|
205
205
|
S: this,
|
|
206
206
|
C: (f, a) => f(...a)
|
|
207
207
|
});
|
|
@@ -211,7 +211,7 @@ var Connection = class {
|
|
|
211
211
|
if (err instanceof ConnectionResetError) {
|
|
212
212
|
log.info("aborting due to transport ConnectionResetError", void 0, {
|
|
213
213
|
F: __dxlog_file,
|
|
214
|
-
L:
|
|
214
|
+
L: 216,
|
|
215
215
|
S: this,
|
|
216
216
|
C: (f, a) => f(...a)
|
|
217
217
|
});
|
|
@@ -219,7 +219,7 @@ var Connection = class {
|
|
|
219
219
|
} else if (err instanceof ConnectivityError) {
|
|
220
220
|
log.info("aborting due to transport ConnectivityError", void 0, {
|
|
221
221
|
F: __dxlog_file,
|
|
222
|
-
L:
|
|
222
|
+
L: 219,
|
|
223
223
|
S: this,
|
|
224
224
|
C: (f, a) => f(...a)
|
|
225
225
|
});
|
|
@@ -229,7 +229,7 @@ var Connection = class {
|
|
|
229
229
|
err
|
|
230
230
|
}, {
|
|
231
231
|
F: __dxlog_file,
|
|
232
|
-
L:
|
|
232
|
+
L: 222,
|
|
233
233
|
S: this,
|
|
234
234
|
C: (f, a) => f(...a)
|
|
235
235
|
});
|
|
@@ -247,7 +247,7 @@ var Connection = class {
|
|
|
247
247
|
id: this._instanceId
|
|
248
248
|
}), {
|
|
249
249
|
F: __dxlog_file,
|
|
250
|
-
L:
|
|
250
|
+
L: 238,
|
|
251
251
|
S: this,
|
|
252
252
|
C: (f, a) => f(...a)
|
|
253
253
|
});
|
|
@@ -257,14 +257,14 @@ var Connection = class {
|
|
|
257
257
|
err
|
|
258
258
|
}, {
|
|
259
259
|
F: __dxlog_file,
|
|
260
|
-
L:
|
|
260
|
+
L: 245,
|
|
261
261
|
S: this,
|
|
262
262
|
C: (f, a) => f(...a)
|
|
263
263
|
});
|
|
264
264
|
if (this._state === ConnectionState.CLOSED || this._state === ConnectionState.ABORTED) {
|
|
265
265
|
log(`abort ignored: already ${this._state}`, this.closeReason, {
|
|
266
266
|
F: __dxlog_file,
|
|
267
|
-
L:
|
|
267
|
+
L: 247,
|
|
268
268
|
S: this,
|
|
269
269
|
C: (f, a) => f(...a)
|
|
270
270
|
});
|
|
@@ -279,7 +279,7 @@ var Connection = class {
|
|
|
279
279
|
try {
|
|
280
280
|
log("aborting protocol... ", void 0, {
|
|
281
281
|
F: __dxlog_file,
|
|
282
|
-
L:
|
|
282
|
+
L: 261,
|
|
283
283
|
S: this,
|
|
284
284
|
C: (f, a) => f(...a)
|
|
285
285
|
});
|
|
@@ -287,7 +287,7 @@ var Connection = class {
|
|
|
287
287
|
} catch (err2) {
|
|
288
288
|
log.catch(err2, void 0, {
|
|
289
289
|
F: __dxlog_file,
|
|
290
|
-
L:
|
|
290
|
+
L: 264,
|
|
291
291
|
S: this,
|
|
292
292
|
C: (f, a) => f(...a)
|
|
293
293
|
});
|
|
@@ -297,7 +297,7 @@ var Connection = class {
|
|
|
297
297
|
} catch (err2) {
|
|
298
298
|
log.catch(err2, void 0, {
|
|
299
299
|
F: __dxlog_file,
|
|
300
|
-
L:
|
|
300
|
+
L: 271,
|
|
301
301
|
S: this,
|
|
302
302
|
C: (f, a) => f(...a)
|
|
303
303
|
});
|
|
@@ -307,7 +307,7 @@ var Connection = class {
|
|
|
307
307
|
} catch (err2) {
|
|
308
308
|
log.catch(err2, void 0, {
|
|
309
309
|
F: __dxlog_file,
|
|
310
|
-
L:
|
|
310
|
+
L: 277,
|
|
311
311
|
S: this,
|
|
312
312
|
C: (f, a) => f(...a)
|
|
313
313
|
});
|
|
@@ -331,7 +331,7 @@ var Connection = class {
|
|
|
331
331
|
peerId: this.ownId
|
|
332
332
|
}, {
|
|
333
333
|
F: __dxlog_file,
|
|
334
|
-
L:
|
|
334
|
+
L: 302,
|
|
335
335
|
S: this,
|
|
336
336
|
C: (f, a) => f(...a)
|
|
337
337
|
});
|
|
@@ -341,7 +341,7 @@ var Connection = class {
|
|
|
341
341
|
} catch (err2) {
|
|
342
342
|
log.catch(err2, void 0, {
|
|
343
343
|
F: __dxlog_file,
|
|
344
|
-
L:
|
|
344
|
+
L: 309,
|
|
345
345
|
S: this,
|
|
346
346
|
C: (f, a) => f(...a)
|
|
347
347
|
});
|
|
@@ -351,7 +351,34 @@ var Connection = class {
|
|
|
351
351
|
} catch (err2) {
|
|
352
352
|
log.catch(err2, void 0, {
|
|
353
353
|
F: __dxlog_file,
|
|
354
|
-
L:
|
|
354
|
+
L: 316,
|
|
355
|
+
S: this,
|
|
356
|
+
C: (f, a) => f(...a)
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
} else {
|
|
360
|
+
log.info(`graceful close requested when we were in ${lastState} state? aborting`, void 0, {
|
|
361
|
+
F: __dxlog_file,
|
|
362
|
+
L: 319,
|
|
363
|
+
S: this,
|
|
364
|
+
C: (f, a) => f(...a)
|
|
365
|
+
});
|
|
366
|
+
try {
|
|
367
|
+
await this._protocol.abort();
|
|
368
|
+
} catch (err2) {
|
|
369
|
+
log.catch(err2, void 0, {
|
|
370
|
+
F: __dxlog_file,
|
|
371
|
+
L: 323,
|
|
372
|
+
S: this,
|
|
373
|
+
C: (f, a) => f(...a)
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
try {
|
|
377
|
+
await this._transport?.destroy();
|
|
378
|
+
} catch (err2) {
|
|
379
|
+
log.catch(err2, void 0, {
|
|
380
|
+
F: __dxlog_file,
|
|
381
|
+
L: 328,
|
|
355
382
|
S: this,
|
|
356
383
|
C: (f, a) => f(...a)
|
|
357
384
|
});
|
|
@@ -361,7 +388,7 @@ var Connection = class {
|
|
|
361
388
|
peerId: this.ownId
|
|
362
389
|
}, {
|
|
363
390
|
F: __dxlog_file,
|
|
364
|
-
L:
|
|
391
|
+
L: 332,
|
|
365
392
|
S: this,
|
|
366
393
|
C: (f, a) => f(...a)
|
|
367
394
|
});
|
|
@@ -404,7 +431,7 @@ var Connection = class {
|
|
|
404
431
|
err
|
|
405
432
|
}, {
|
|
406
433
|
F: __dxlog_file,
|
|
407
|
-
L:
|
|
434
|
+
L: 370,
|
|
408
435
|
S: this,
|
|
409
436
|
C: (f, a) => f(...a)
|
|
410
437
|
});
|
|
@@ -417,7 +444,7 @@ var Connection = class {
|
|
|
417
444
|
async signal(msg) {
|
|
418
445
|
invariant(msg.sessionId, void 0, {
|
|
419
446
|
F: __dxlog_file,
|
|
420
|
-
L:
|
|
447
|
+
L: 379,
|
|
421
448
|
S: this,
|
|
422
449
|
A: [
|
|
423
450
|
"msg.sessionId",
|
|
@@ -427,7 +454,7 @@ var Connection = class {
|
|
|
427
454
|
if (!msg.sessionId.equals(this.sessionId)) {
|
|
428
455
|
log("dropping signal for incorrect session id", void 0, {
|
|
429
456
|
F: __dxlog_file,
|
|
430
|
-
L:
|
|
457
|
+
L: 381,
|
|
431
458
|
S: this,
|
|
432
459
|
C: (f, a) => f(...a)
|
|
433
460
|
});
|
|
@@ -435,7 +462,7 @@ var Connection = class {
|
|
|
435
462
|
}
|
|
436
463
|
invariant(msg.data.signal || msg.data.signalBatch, void 0, {
|
|
437
464
|
F: __dxlog_file,
|
|
438
|
-
L:
|
|
465
|
+
L: 384,
|
|
439
466
|
S: this,
|
|
440
467
|
A: [
|
|
441
468
|
"msg.data.signal || msg.data.signalBatch",
|
|
@@ -444,7 +471,7 @@ var Connection = class {
|
|
|
444
471
|
});
|
|
445
472
|
invariant(msg.author?.equals(this.remoteId), void 0, {
|
|
446
473
|
F: __dxlog_file,
|
|
447
|
-
L:
|
|
474
|
+
L: 385,
|
|
448
475
|
S: this,
|
|
449
476
|
A: [
|
|
450
477
|
"msg.author?.equals(this.remoteId)",
|
|
@@ -453,7 +480,7 @@ var Connection = class {
|
|
|
453
480
|
});
|
|
454
481
|
invariant(msg.recipient?.equals(this.ownId), void 0, {
|
|
455
482
|
F: __dxlog_file,
|
|
456
|
-
L:
|
|
483
|
+
L: 386,
|
|
457
484
|
S: this,
|
|
458
485
|
A: [
|
|
459
486
|
"msg.recipient?.equals(this.ownId)",
|
|
@@ -477,7 +504,7 @@ var Connection = class {
|
|
|
477
504
|
msg: msg.data
|
|
478
505
|
}, {
|
|
479
506
|
F: __dxlog_file,
|
|
480
|
-
L:
|
|
507
|
+
L: 395,
|
|
481
508
|
S: this,
|
|
482
509
|
C: (f, a) => f(...a)
|
|
483
510
|
});
|
|
@@ -485,7 +512,7 @@ var Connection = class {
|
|
|
485
512
|
} else {
|
|
486
513
|
invariant(this._transport, "Connection not ready to accept signals.", {
|
|
487
514
|
F: __dxlog_file,
|
|
488
|
-
L:
|
|
515
|
+
L: 398,
|
|
489
516
|
S: this,
|
|
490
517
|
A: [
|
|
491
518
|
"this._transport",
|
|
@@ -498,7 +525,7 @@ var Connection = class {
|
|
|
498
525
|
msg: msg.data
|
|
499
526
|
}, {
|
|
500
527
|
F: __dxlog_file,
|
|
501
|
-
L:
|
|
528
|
+
L: 399,
|
|
502
529
|
S: this,
|
|
503
530
|
C: (f, a) => f(...a)
|
|
504
531
|
});
|
|
@@ -516,13 +543,13 @@ var Connection = class {
|
|
|
516
543
|
peerId: this.ownId
|
|
517
544
|
}, {
|
|
518
545
|
F: __dxlog_file,
|
|
519
|
-
L:
|
|
546
|
+
L: 410,
|
|
520
547
|
S: this,
|
|
521
548
|
C: (f, a) => f(...a)
|
|
522
549
|
});
|
|
523
550
|
invariant(state !== this._state, "Already in this state.", {
|
|
524
551
|
F: __dxlog_file,
|
|
525
|
-
L:
|
|
552
|
+
L: 411,
|
|
526
553
|
S: this,
|
|
527
554
|
A: [
|
|
528
555
|
"state !== this._state",
|
|
@@ -545,9 +572,9 @@ import { Context as Context2 } from "@dxos/context";
|
|
|
545
572
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
546
573
|
import { PublicKey as PublicKey2 } from "@dxos/keys";
|
|
547
574
|
import { log as log2 } from "@dxos/log";
|
|
548
|
-
import { schema, TimeoutError } from "@dxos/protocols";
|
|
575
|
+
import { schema, TimeoutError as TimeoutError2 } from "@dxos/protocols";
|
|
549
576
|
import { ComplexMap } from "@dxos/util";
|
|
550
|
-
var __dxlog_file2 = "/home/
|
|
577
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/signal/swarm-messenger.ts";
|
|
551
578
|
var SwarmMessage = schema.getCodecForType("dxos.mesh.swarm.SwarmMessage");
|
|
552
579
|
var SwarmMessenger = class {
|
|
553
580
|
constructor({ sendMessage, onSignal, onOffer, topic }) {
|
|
@@ -730,7 +757,7 @@ var SwarmMessenger = class {
|
|
|
730
757
|
}
|
|
731
758
|
});
|
|
732
759
|
} catch (err) {
|
|
733
|
-
if (err instanceof
|
|
760
|
+
if (err instanceof TimeoutError2) {
|
|
734
761
|
log2.info("timeout sending answer to offer", {
|
|
735
762
|
err
|
|
736
763
|
}, {
|
|
@@ -810,7 +837,7 @@ function _ts_decorate2(decorators, target, key, desc) {
|
|
|
810
837
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
811
838
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
812
839
|
}
|
|
813
|
-
var __dxlog_file3 = "/home/
|
|
840
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/peer.ts";
|
|
814
841
|
var ConnectionDisplacedError = class extends SystemError {
|
|
815
842
|
constructor() {
|
|
816
843
|
super("Connection displaced by remote initiator.");
|
|
@@ -1288,7 +1315,7 @@ function _ts_decorate3(decorators, target, key, desc) {
|
|
|
1288
1315
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1289
1316
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1290
1317
|
}
|
|
1291
|
-
var __dxlog_file4 = "/home/
|
|
1318
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/swarm.ts";
|
|
1292
1319
|
var INITIATION_DELAY = 100;
|
|
1293
1320
|
var getClassName = (obj) => Object.getPrototypeOf(obj).constructor.name;
|
|
1294
1321
|
var Swarm = class {
|
|
@@ -1779,7 +1806,7 @@ import { Event as Event4, EventSubscriptions } from "@dxos/async";
|
|
|
1779
1806
|
import { PublicKey as PublicKey5 } from "@dxos/keys";
|
|
1780
1807
|
import { log as log5 } from "@dxos/log";
|
|
1781
1808
|
import { ComplexMap as ComplexMap3 } from "@dxos/util";
|
|
1782
|
-
var __dxlog_file5 = "/home/
|
|
1809
|
+
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/swarm-mapper.ts";
|
|
1783
1810
|
var SwarmMapper = class {
|
|
1784
1811
|
get peers() {
|
|
1785
1812
|
return Array.from(this._peers.values());
|
|
@@ -1851,7 +1878,7 @@ import { PublicKey as PublicKey6 } from "@dxos/keys";
|
|
|
1851
1878
|
import { log as log6 } from "@dxos/log";
|
|
1852
1879
|
import { CancelledError as CancelledError3 } from "@dxos/protocols";
|
|
1853
1880
|
import { ComplexMap as ComplexMap4 } from "@dxos/util";
|
|
1854
|
-
var __dxlog_file6 = "/home/
|
|
1881
|
+
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/connection-limiter.ts";
|
|
1855
1882
|
var MAX_CONCURRENT_INITIATING_CONNECTIONS = 50;
|
|
1856
1883
|
var ConnectionLimiter = class {
|
|
1857
1884
|
constructor({ maxConcurrentInitConnections = MAX_CONCURRENT_INITIATING_CONNECTIONS } = {}) {
|
|
@@ -1930,6 +1957,7 @@ import { Event as Event5 } from "@dxos/async";
|
|
|
1930
1957
|
import { raise } from "@dxos/debug";
|
|
1931
1958
|
import { PublicKey as PublicKey7 } from "@dxos/keys";
|
|
1932
1959
|
import { ComplexMap as ComplexMap5 } from "@dxos/util";
|
|
1960
|
+
var CONNECTION_GC_THRESHOLD = 1e3 * 60 * 15;
|
|
1933
1961
|
var EventType;
|
|
1934
1962
|
(function(EventType2) {
|
|
1935
1963
|
EventType2["CONNECTION_STATE_CHANGED"] = "CONNECTION_STATE_CHANGED";
|
|
@@ -1970,13 +1998,15 @@ var ConnectionLog = class {
|
|
|
1970
1998
|
sessionId: connection.sessionId,
|
|
1971
1999
|
transport: connection.transport && Object.getPrototypeOf(connection.transport).constructor.name,
|
|
1972
2000
|
protocolExtensions: [],
|
|
1973
|
-
events: []
|
|
2001
|
+
events: [],
|
|
2002
|
+
lastUpdate: /* @__PURE__ */ new Date()
|
|
1974
2003
|
};
|
|
1975
2004
|
info.connections.push(connectionInfo);
|
|
1976
2005
|
this.update.emit();
|
|
1977
2006
|
connection.stateChanged.on((state) => {
|
|
1978
2007
|
connectionInfo.state = state;
|
|
1979
2008
|
connectionInfo.closeReason = connection.closeReason;
|
|
2009
|
+
connectionInfo.lastUpdate = /* @__PURE__ */ new Date();
|
|
1980
2010
|
connectionInfo.events.push({
|
|
1981
2011
|
type: EventType.CONNECTION_STATE_CHANGED,
|
|
1982
2012
|
newState: state
|
|
@@ -1987,8 +2017,10 @@ var ConnectionLog = class {
|
|
|
1987
2017
|
connectionInfo.readBufferSize = stats.readBufferSize;
|
|
1988
2018
|
connectionInfo.writeBufferSize = stats.writeBufferSize;
|
|
1989
2019
|
connectionInfo.streams = stats.channels;
|
|
2020
|
+
connectionInfo.lastUpdate = /* @__PURE__ */ new Date();
|
|
1990
2021
|
this.update.emit();
|
|
1991
2022
|
});
|
|
2023
|
+
gcSwarm(info);
|
|
1992
2024
|
});
|
|
1993
2025
|
}
|
|
1994
2026
|
leftSwarm(swarm) {
|
|
@@ -1996,6 +2028,11 @@ var ConnectionLog = class {
|
|
|
1996
2028
|
this.update.emit();
|
|
1997
2029
|
}
|
|
1998
2030
|
};
|
|
2031
|
+
var gcSwarm = (swarm) => {
|
|
2032
|
+
swarm.connections = swarm.connections?.filter((connection) => {
|
|
2033
|
+
return connection.lastUpdate ? Date.now() - connection.lastUpdate.getTime() < CONNECTION_GC_THRESHOLD : true;
|
|
2034
|
+
});
|
|
2035
|
+
};
|
|
1999
2036
|
|
|
2000
2037
|
// packages/core/mesh/network-manager/src/network-manager.ts
|
|
2001
2038
|
import { Event as Event6 } from "@dxos/async";
|
|
@@ -2006,7 +2043,7 @@ import { Messenger } from "@dxos/messaging";
|
|
|
2006
2043
|
import { trace as trace3 } from "@dxos/protocols";
|
|
2007
2044
|
import { ConnectionState as ConnectionState2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
2008
2045
|
import { ComplexMap as ComplexMap6 } from "@dxos/util";
|
|
2009
|
-
var __dxlog_file7 = "/home/
|
|
2046
|
+
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/network-manager.ts";
|
|
2010
2047
|
var NetworkManager = class {
|
|
2011
2048
|
constructor({ transportFactory, signalManager, log: log1 }) {
|
|
2012
2049
|
/**
|
|
@@ -2242,7 +2279,7 @@ var NetworkManager = class {
|
|
|
2242
2279
|
|
|
2243
2280
|
// packages/core/mesh/network-manager/src/topology/fully-connected-topology.ts
|
|
2244
2281
|
import { invariant as invariant7 } from "@dxos/invariant";
|
|
2245
|
-
var __dxlog_file8 = "/home/
|
|
2282
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/topology/fully-connected-topology.ts";
|
|
2246
2283
|
var FullyConnectedTopology = class {
|
|
2247
2284
|
toString() {
|
|
2248
2285
|
return "FullyConnectedTopology";
|
|
@@ -2285,7 +2322,7 @@ var FullyConnectedTopology = class {
|
|
|
2285
2322
|
import distance from "xor-distance";
|
|
2286
2323
|
import { invariant as invariant8 } from "@dxos/invariant";
|
|
2287
2324
|
import { log as log8 } from "@dxos/log";
|
|
2288
|
-
var __dxlog_file9 = "/home/
|
|
2325
|
+
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/topology/mmst-topology.ts";
|
|
2289
2326
|
var MMSTTopology = class {
|
|
2290
2327
|
constructor({ originateConnections = 2, maxPeers = 4, sampleSize = 10 } = {}) {
|
|
2291
2328
|
this._sampleCollected = false;
|
|
@@ -2394,7 +2431,7 @@ var sortByXorDistance = (keys, reference) => keys.sort((a, b) => distance.gt(dis
|
|
|
2394
2431
|
// packages/core/mesh/network-manager/src/topology/star-topology.ts
|
|
2395
2432
|
import { invariant as invariant9 } from "@dxos/invariant";
|
|
2396
2433
|
import { log as log9 } from "@dxos/log";
|
|
2397
|
-
var __dxlog_file10 = "/home/
|
|
2434
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/topology/star-topology.ts";
|
|
2398
2435
|
var StarTopology = class {
|
|
2399
2436
|
constructor(_centralPeer) {
|
|
2400
2437
|
this._centralPeer = _centralPeer;
|
|
@@ -2505,7 +2542,7 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
2505
2542
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2506
2543
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2507
2544
|
}
|
|
2508
|
-
var __dxlog_file11 = "/home/
|
|
2545
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/memory-transport.ts";
|
|
2509
2546
|
var MEMORY_TRANSPORT_DELAY = 1;
|
|
2510
2547
|
var createStreamDelay = (delay) => {
|
|
2511
2548
|
return new Transform({
|
|
@@ -2703,7 +2740,7 @@ try {
|
|
|
2703
2740
|
}
|
|
2704
2741
|
|
|
2705
2742
|
// packages/core/mesh/network-manager/src/transport/simplepeer-transport.ts
|
|
2706
|
-
var __dxlog_file12 = "/home/
|
|
2743
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/simplepeer-transport.ts";
|
|
2707
2744
|
var SimplePeerTransport = class {
|
|
2708
2745
|
constructor(params) {
|
|
2709
2746
|
this.params = params;
|
|
@@ -2771,12 +2808,20 @@ var SimplePeerTransport = class {
|
|
|
2771
2808
|
if (err.errorDetail === "sctp-failure") {
|
|
2772
2809
|
this.errors.raise(new ConnectionResetError2("sctp-failure from RTCError", err));
|
|
2773
2810
|
} else {
|
|
2811
|
+
log11.info("unknown RTCError", {
|
|
2812
|
+
err
|
|
2813
|
+
}, {
|
|
2814
|
+
F: __dxlog_file12,
|
|
2815
|
+
L: 74,
|
|
2816
|
+
S: this,
|
|
2817
|
+
C: (f, a) => f(...a)
|
|
2818
|
+
});
|
|
2774
2819
|
this.errors.raise(new UnknownProtocolError2("unknown RTCError", err));
|
|
2775
2820
|
}
|
|
2776
2821
|
} else if ("code" in err) {
|
|
2777
2822
|
log11.info("simple-peer error", err, {
|
|
2778
2823
|
F: __dxlog_file12,
|
|
2779
|
-
L:
|
|
2824
|
+
L: 79,
|
|
2780
2825
|
S: this,
|
|
2781
2826
|
C: (f, a) => f(...a)
|
|
2782
2827
|
});
|
|
@@ -2784,10 +2829,12 @@ var SimplePeerTransport = class {
|
|
|
2784
2829
|
case "ERR_WEBRTC_SUPPORT":
|
|
2785
2830
|
this.errors.raise(new ProtocolError2("WebRTC not supported", err));
|
|
2786
2831
|
break;
|
|
2832
|
+
case "ERR_SIGNALING":
|
|
2833
|
+
this.errors.raise(new ConnectivityError2("signaling failure", err));
|
|
2834
|
+
break;
|
|
2787
2835
|
case "ERR_ICE_CONNECTION_FAILURE":
|
|
2788
2836
|
case "ERR_DATA_CHANNEL":
|
|
2789
2837
|
case "ERR_CONNECTION_FAILURE":
|
|
2790
|
-
case "ERR_SIGNALING":
|
|
2791
2838
|
this.errors.raise(new ConnectivityError2("unknown communication failure", err));
|
|
2792
2839
|
break;
|
|
2793
2840
|
case "ERR_CREATE_OFFER":
|
|
@@ -2804,7 +2851,7 @@ var SimplePeerTransport = class {
|
|
|
2804
2851
|
} else {
|
|
2805
2852
|
log11.info("unknown peer connection error", err, {
|
|
2806
2853
|
F: __dxlog_file12,
|
|
2807
|
-
L:
|
|
2854
|
+
L: 105,
|
|
2808
2855
|
S: this,
|
|
2809
2856
|
C: (f, a) => f(...a)
|
|
2810
2857
|
});
|
|
@@ -2818,7 +2865,7 @@ var SimplePeerTransport = class {
|
|
|
2818
2865
|
stats
|
|
2819
2866
|
}, {
|
|
2820
2867
|
F: __dxlog_file12,
|
|
2821
|
-
L:
|
|
2868
|
+
L: 113,
|
|
2822
2869
|
S: this,
|
|
2823
2870
|
C: (f, a) => f(...a)
|
|
2824
2871
|
});
|
|
@@ -2827,7 +2874,7 @@ var SimplePeerTransport = class {
|
|
|
2827
2874
|
} catch (err2) {
|
|
2828
2875
|
log11.catch(err2, void 0, {
|
|
2829
2876
|
F: __dxlog_file12,
|
|
2830
|
-
L:
|
|
2877
|
+
L: 120,
|
|
2831
2878
|
S: this,
|
|
2832
2879
|
C: (f, a) => f(...a)
|
|
2833
2880
|
});
|
|
@@ -2838,7 +2885,7 @@ var SimplePeerTransport = class {
|
|
|
2838
2885
|
id: this._instanceId
|
|
2839
2886
|
}), {
|
|
2840
2887
|
F: __dxlog_file12,
|
|
2841
|
-
L:
|
|
2888
|
+
L: 125,
|
|
2842
2889
|
S: this,
|
|
2843
2890
|
C: (f, a) => f(...a)
|
|
2844
2891
|
});
|
|
@@ -2846,7 +2893,7 @@ var SimplePeerTransport = class {
|
|
|
2846
2893
|
async destroy() {
|
|
2847
2894
|
log11("closing...", void 0, {
|
|
2848
2895
|
F: __dxlog_file12,
|
|
2849
|
-
L:
|
|
2896
|
+
L: 129,
|
|
2850
2897
|
S: this,
|
|
2851
2898
|
C: (f, a) => f(...a)
|
|
2852
2899
|
});
|
|
@@ -2859,7 +2906,7 @@ var SimplePeerTransport = class {
|
|
|
2859
2906
|
this.closed.emit();
|
|
2860
2907
|
log11("closed", void 0, {
|
|
2861
2908
|
F: __dxlog_file12,
|
|
2862
|
-
L:
|
|
2909
|
+
L: 137,
|
|
2863
2910
|
S: this,
|
|
2864
2911
|
C: (f, a) => f(...a)
|
|
2865
2912
|
});
|
|
@@ -2892,7 +2939,7 @@ import { PublicKey as PublicKey11 } from "@dxos/keys";
|
|
|
2892
2939
|
import { log as log12 } from "@dxos/log";
|
|
2893
2940
|
import { ConnectionState as ConnectionState3 } from "@dxos/protocols/proto/dxos/mesh/bridge";
|
|
2894
2941
|
import { ComplexMap as ComplexMap8 } from "@dxos/util";
|
|
2895
|
-
var __dxlog_file13 = "/home/
|
|
2942
|
+
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/simplepeer-transport-service.ts";
|
|
2896
2943
|
var SimplePeerTransportService = class {
|
|
2897
2944
|
constructor(_webrtcConfig) {
|
|
2898
2945
|
this._webrtcConfig = _webrtcConfig;
|
|
@@ -3032,10 +3079,10 @@ import { ErrorStream as ErrorStream5 } from "@dxos/debug";
|
|
|
3032
3079
|
import { invariant as invariant13 } from "@dxos/invariant";
|
|
3033
3080
|
import { PublicKey as PublicKey12 } from "@dxos/keys";
|
|
3034
3081
|
import { log as log13 } from "@dxos/log";
|
|
3035
|
-
import { ConnectionResetError as ConnectionResetError3, TimeoutError as
|
|
3082
|
+
import { ConnectionResetError as ConnectionResetError3, TimeoutError as TimeoutError3, ProtocolError as ProtocolError3, ConnectivityError as ConnectivityError3, UnknownProtocolError as UnknownProtocolError3 } from "@dxos/protocols";
|
|
3036
3083
|
import { ConnectionState as ConnectionState4 } from "@dxos/protocols/proto/dxos/mesh/bridge";
|
|
3037
3084
|
import { arrayToBuffer } from "@dxos/util";
|
|
3038
|
-
var __dxlog_file14 = "/home/
|
|
3085
|
+
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/simplepeer-transport-proxy.ts";
|
|
3039
3086
|
var RESP_MIN_THRESHOLD = 500;
|
|
3040
3087
|
var TIMEOUT_THRESHOLD = 10;
|
|
3041
3088
|
var SimplePeerTransportProxy = class {
|
|
@@ -3088,9 +3135,9 @@ var SimplePeerTransportProxy = class {
|
|
|
3088
3135
|
}
|
|
3089
3136
|
this._timeoutCount = 0;
|
|
3090
3137
|
}, (err) => {
|
|
3091
|
-
if (err instanceof
|
|
3138
|
+
if (err instanceof TimeoutError3 || err.constructor.name === "TimeoutError") {
|
|
3092
3139
|
if (this._timeoutCount++ > TIMEOUT_THRESHOLD) {
|
|
3093
|
-
throw new
|
|
3140
|
+
throw new TimeoutError3(`too many timeoutes (${this._timeoutCount} > ${TIMEOUT_THRESHOLD}`);
|
|
3094
3141
|
} else {
|
|
3095
3142
|
log13("timeout error, but still invoking callback", void 0, {
|
|
3096
3143
|
F: __dxlog_file14,
|
|
@@ -3227,7 +3274,7 @@ var decodeError = (err) => {
|
|
|
3227
3274
|
if (message.includes("CONNECTION_RESET")) {
|
|
3228
3275
|
return new ConnectionResetError3(message);
|
|
3229
3276
|
} else if (message.includes("TIMEOUT")) {
|
|
3230
|
-
return new
|
|
3277
|
+
return new TimeoutError3(message);
|
|
3231
3278
|
} else if (message.includes("PROTOCOL_ERROR")) {
|
|
3232
3279
|
return new ProtocolError3(message);
|
|
3233
3280
|
} else if (message.includes("CONNECTIVITY_ERROR")) {
|
|
@@ -3254,7 +3301,7 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
3254
3301
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3255
3302
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3256
3303
|
}
|
|
3257
|
-
var __dxlog_file15 = "/home/
|
|
3304
|
+
var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/libdatachannel-transport.ts";
|
|
3258
3305
|
var DATACHANNEL_LABEL = "dxos.mesh.transport";
|
|
3259
3306
|
var MAX_BUFFERED_AMOUNT = 64 * 1024;
|
|
3260
3307
|
var MAX_MESSAGE_SIZE = 64 * 1024;
|
|
@@ -3407,16 +3454,21 @@ var LibDataChannelTransport = class {
|
|
|
3407
3454
|
const duplex = new Duplex2({
|
|
3408
3455
|
read: () => {
|
|
3409
3456
|
},
|
|
3410
|
-
write: (chunk, encoding, callback) => {
|
|
3457
|
+
write: async (chunk, encoding, callback) => {
|
|
3411
3458
|
if (chunk.length > MAX_MESSAGE_SIZE) {
|
|
3412
3459
|
this.errors.raise(new Error(`message too large: ${chunk.length} > ${MAX_MESSAGE_SIZE}`));
|
|
3413
3460
|
}
|
|
3414
|
-
|
|
3461
|
+
try {
|
|
3462
|
+
dataChannel.send(chunk);
|
|
3463
|
+
} catch (err) {
|
|
3464
|
+
this.errors.raise(err);
|
|
3465
|
+
await this._close();
|
|
3466
|
+
}
|
|
3415
3467
|
if (this._channel.bufferedAmount > MAX_BUFFERED_AMOUNT) {
|
|
3416
3468
|
if (this._writeCallback !== null) {
|
|
3417
3469
|
log14.error("consumer trying to write before we're ready for more data", void 0, {
|
|
3418
3470
|
F: __dxlog_file15,
|
|
3419
|
-
L:
|
|
3471
|
+
L: 143,
|
|
3420
3472
|
S: this,
|
|
3421
3473
|
C: (f, a) => f(...a)
|
|
3422
3474
|
});
|
|
@@ -3441,7 +3493,7 @@ var LibDataChannelTransport = class {
|
|
|
3441
3493
|
err
|
|
3442
3494
|
}, {
|
|
3443
3495
|
F: __dxlog_file15,
|
|
3444
|
-
L:
|
|
3496
|
+
L: 163,
|
|
3445
3497
|
S: this,
|
|
3446
3498
|
C: (f, a) => f(...a)
|
|
3447
3499
|
});
|
|
@@ -3478,7 +3530,7 @@ var LibDataChannelTransport = class {
|
|
|
3478
3530
|
peer
|
|
3479
3531
|
}, {
|
|
3480
3532
|
F: __dxlog_file15,
|
|
3481
|
-
L:
|
|
3533
|
+
L: 198,
|
|
3482
3534
|
S: this,
|
|
3483
3535
|
C: (f, a) => f(...a)
|
|
3484
3536
|
});
|
|
@@ -3506,7 +3558,7 @@ var LibDataChannelTransport = class {
|
|
|
3506
3558
|
err
|
|
3507
3559
|
}, {
|
|
3508
3560
|
F: __dxlog_file15,
|
|
3509
|
-
L:
|
|
3561
|
+
L: 209,
|
|
3510
3562
|
S: this,
|
|
3511
3563
|
C: (f, a) => f(...a)
|
|
3512
3564
|
});
|
|
@@ -3526,7 +3578,7 @@ var LibDataChannelTransport = class {
|
|
|
3526
3578
|
err
|
|
3527
3579
|
}, {
|
|
3528
3580
|
F: __dxlog_file15,
|
|
3529
|
-
L:
|
|
3581
|
+
L: 220,
|
|
3530
3582
|
S: this,
|
|
3531
3583
|
C: (f, a) => f(...a)
|
|
3532
3584
|
});
|
|
@@ -3545,7 +3597,7 @@ var LibDataChannelTransport = class {
|
|
|
3545
3597
|
signal
|
|
3546
3598
|
}, {
|
|
3547
3599
|
F: __dxlog_file15,
|
|
3548
|
-
L:
|
|
3600
|
+
L: 231,
|
|
3549
3601
|
S: this,
|
|
3550
3602
|
C: (f, a) => f(...a)
|
|
3551
3603
|
});
|
|
@@ -3554,7 +3606,7 @@ var LibDataChannelTransport = class {
|
|
|
3554
3606
|
}).catch((err) => {
|
|
3555
3607
|
log14.catch(err, void 0, {
|
|
3556
3608
|
F: __dxlog_file15,
|
|
3557
|
-
L:
|
|
3609
|
+
L: 236,
|
|
3558
3610
|
S: this,
|
|
3559
3611
|
C: (f, a) => f(...a)
|
|
3560
3612
|
});
|
|
@@ -3647,4 +3699,4 @@ export {
|
|
|
3647
3699
|
TcpTransport,
|
|
3648
3700
|
createTeleportProtocolFactory
|
|
3649
3701
|
};
|
|
3650
|
-
//# sourceMappingURL=chunk-
|
|
3702
|
+
//# sourceMappingURL=chunk-4HITD6WI.mjs.map
|