@dxos/network-manager 0.3.0 → 0.3.1-main.2d5b138
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-LN6AHVN6.mjs → chunk-UE5KR5PC.mjs} +198 -123
- package/dist/lib/browser/chunk-UE5KR5PC.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/index.cjs +189 -114
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +189 -114
- package/dist/lib/node/testing/index.cjs.map +3 -3
- package/dist/types/src/swarm/connection.d.ts +1 -0
- package/dist/types/src/swarm/connection.d.ts.map +1 -1
- package/dist/types/src/swarm/peer.d.ts +1 -1
- package/dist/types/src/swarm/peer.d.ts.map +1 -1
- package/dist/types/src/swarm/swarm.d.ts.map +1 -1
- package/package.json +17 -17
- package/src/swarm/connection.ts +27 -5
- package/src/swarm/peer.ts +47 -11
- package/src/swarm/swarm.ts +10 -7
- package/dist/lib/browser/chunk-LN6AHVN6.mjs.map +0 -7
|
@@ -4,7 +4,7 @@ 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, synchronized } from "@dxos/async";
|
|
7
|
+
import { DeferredTask, Event, sleep, scheduleTask, 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";
|
|
@@ -21,8 +21,9 @@ 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 = "/
|
|
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
|
+
var TRANSPORT_CONNECTION_TIMEOUT = 1e4;
|
|
26
27
|
var MAX_SIGNALLING_DELAY = 300;
|
|
27
28
|
var ConnectionState;
|
|
28
29
|
(function(ConnectionState5) {
|
|
@@ -78,6 +79,7 @@ var Connection = class {
|
|
|
78
79
|
this._transportFactory = _transportFactory;
|
|
79
80
|
this._callbacks = _callbacks;
|
|
80
81
|
this._ctx = new Context();
|
|
82
|
+
this.connectedTimeoutContext = new Context();
|
|
81
83
|
this._state = ConnectionState.CREATED;
|
|
82
84
|
this._incomingSignalBuffer = [];
|
|
83
85
|
this._outgoingSignalBuffer = [];
|
|
@@ -96,7 +98,7 @@ var Connection = class {
|
|
|
96
98
|
initiator: this.initiator
|
|
97
99
|
}, {
|
|
98
100
|
F: __dxlog_file,
|
|
99
|
-
L:
|
|
101
|
+
L: 129,
|
|
100
102
|
S: this,
|
|
101
103
|
C: (f, a) => f(...a)
|
|
102
104
|
});
|
|
@@ -116,7 +118,7 @@ var Connection = class {
|
|
|
116
118
|
async openConnection() {
|
|
117
119
|
invariant(this._state === ConnectionState.INITIAL, "Invalid state.", {
|
|
118
120
|
F: __dxlog_file,
|
|
119
|
-
L:
|
|
121
|
+
L: 154,
|
|
120
122
|
S: this,
|
|
121
123
|
A: [
|
|
122
124
|
"this._state === ConnectionState.INITIAL",
|
|
@@ -127,7 +129,7 @@ var Connection = class {
|
|
|
127
129
|
id: this._instanceId
|
|
128
130
|
}), {
|
|
129
131
|
F: __dxlog_file,
|
|
130
|
-
L:
|
|
132
|
+
L: 155,
|
|
131
133
|
S: this,
|
|
132
134
|
C: (f, a) => f(...a)
|
|
133
135
|
});
|
|
@@ -139,7 +141,7 @@ var Connection = class {
|
|
|
139
141
|
initiator: this.initiator
|
|
140
142
|
}, {
|
|
141
143
|
F: __dxlog_file,
|
|
142
|
-
L:
|
|
144
|
+
L: 156,
|
|
143
145
|
S: this,
|
|
144
146
|
C: (f, a) => f(...a)
|
|
145
147
|
});
|
|
@@ -150,15 +152,24 @@ var Connection = class {
|
|
|
150
152
|
this._protocol.stream.on("close", () => {
|
|
151
153
|
log("protocol stream closed", void 0, {
|
|
152
154
|
F: __dxlog_file,
|
|
153
|
-
L:
|
|
155
|
+
L: 173,
|
|
154
156
|
S: this,
|
|
155
157
|
C: (f, a) => f(...a)
|
|
156
158
|
});
|
|
157
159
|
this.close(new ProtocolError("protocol stream closed")).catch((err) => this.errors.raise(err));
|
|
158
160
|
});
|
|
161
|
+
scheduleTask(this.connectedTimeoutContext, async () => {
|
|
162
|
+
log.warn("timeout waiting for transport to connect, aborting", void 0, {
|
|
163
|
+
F: __dxlog_file,
|
|
164
|
+
L: 180,
|
|
165
|
+
S: this,
|
|
166
|
+
C: (f, a) => f(...a)
|
|
167
|
+
});
|
|
168
|
+
await this.abort().catch((err) => this.errors.raise(err));
|
|
169
|
+
}, TRANSPORT_CONNECTION_TIMEOUT);
|
|
159
170
|
invariant(!this._transport, void 0, {
|
|
160
171
|
F: __dxlog_file,
|
|
161
|
-
L:
|
|
172
|
+
L: 186,
|
|
162
173
|
S: this,
|
|
163
174
|
A: [
|
|
164
175
|
"!this._transport",
|
|
@@ -170,26 +181,27 @@ var Connection = class {
|
|
|
170
181
|
stream: this._protocol.stream,
|
|
171
182
|
sendSignal: async (signal) => this._sendSignal(signal)
|
|
172
183
|
});
|
|
173
|
-
this._transport.connected.once(() => {
|
|
184
|
+
this._transport.connected.once(async () => {
|
|
174
185
|
this._changeState(ConnectionState.CONNECTED);
|
|
186
|
+
await this.connectedTimeoutContext.dispose();
|
|
175
187
|
this._callbacks?.onConnected?.();
|
|
176
188
|
});
|
|
177
189
|
this._transport.closed.once(() => {
|
|
178
190
|
this._transport = void 0;
|
|
179
191
|
log("abort triggered by transport close", void 0, {
|
|
180
192
|
F: __dxlog_file,
|
|
181
|
-
L:
|
|
193
|
+
L: 201,
|
|
182
194
|
S: this,
|
|
183
195
|
C: (f, a) => f(...a)
|
|
184
196
|
});
|
|
185
197
|
this.abort().catch((err) => this.errors.raise(err));
|
|
186
198
|
});
|
|
187
|
-
this._transport.errors.handle((err) => {
|
|
199
|
+
this._transport.errors.handle(async (err) => {
|
|
188
200
|
log("transport error:", {
|
|
189
201
|
err
|
|
190
202
|
}, {
|
|
191
203
|
F: __dxlog_file,
|
|
192
|
-
L:
|
|
204
|
+
L: 206,
|
|
193
205
|
S: this,
|
|
194
206
|
C: (f, a) => f(...a)
|
|
195
207
|
});
|
|
@@ -199,7 +211,7 @@ var Connection = class {
|
|
|
199
211
|
if (err instanceof ConnectionResetError) {
|
|
200
212
|
log.warn("aborting due to transport ConnectionResetError", void 0, {
|
|
201
213
|
F: __dxlog_file,
|
|
202
|
-
L:
|
|
214
|
+
L: 213,
|
|
203
215
|
S: this,
|
|
204
216
|
C: (f, a) => f(...a)
|
|
205
217
|
});
|
|
@@ -207,7 +219,7 @@ var Connection = class {
|
|
|
207
219
|
} else if (err instanceof ConnectivityError) {
|
|
208
220
|
log.warn("aborting due to transport ConnectivityError", void 0, {
|
|
209
221
|
F: __dxlog_file,
|
|
210
|
-
L:
|
|
222
|
+
L: 216,
|
|
211
223
|
S: this,
|
|
212
224
|
C: (f, a) => f(...a)
|
|
213
225
|
});
|
|
@@ -217,12 +229,13 @@ var Connection = class {
|
|
|
217
229
|
err
|
|
218
230
|
}, {
|
|
219
231
|
F: __dxlog_file,
|
|
220
|
-
L:
|
|
232
|
+
L: 219,
|
|
221
233
|
S: this,
|
|
222
234
|
C: (f, a) => f(...a)
|
|
223
235
|
});
|
|
224
236
|
}
|
|
225
237
|
if (this._state !== ConnectionState.CLOSED && this._state !== ConnectionState.CLOSING) {
|
|
238
|
+
await this.connectedTimeoutContext.dispose();
|
|
226
239
|
this.errors.raise(err);
|
|
227
240
|
}
|
|
228
241
|
});
|
|
@@ -234,7 +247,7 @@ var Connection = class {
|
|
|
234
247
|
id: this._instanceId
|
|
235
248
|
}), {
|
|
236
249
|
F: __dxlog_file,
|
|
237
|
-
L:
|
|
250
|
+
L: 235,
|
|
238
251
|
S: this,
|
|
239
252
|
C: (f, a) => f(...a)
|
|
240
253
|
});
|
|
@@ -244,30 +257,29 @@ var Connection = class {
|
|
|
244
257
|
err
|
|
245
258
|
}, {
|
|
246
259
|
F: __dxlog_file,
|
|
247
|
-
L:
|
|
260
|
+
L: 242,
|
|
248
261
|
S: this,
|
|
249
262
|
C: (f, a) => f(...a)
|
|
250
263
|
});
|
|
251
264
|
if (this._state === ConnectionState.CLOSED || this._state === ConnectionState.ABORTED) {
|
|
252
265
|
log(`abort ignored: already ${this._state}`, this.closeReason, {
|
|
253
266
|
F: __dxlog_file,
|
|
254
|
-
L:
|
|
267
|
+
L: 244,
|
|
255
268
|
S: this,
|
|
256
269
|
C: (f, a) => f(...a)
|
|
257
270
|
});
|
|
258
271
|
return;
|
|
259
272
|
}
|
|
273
|
+
await this.connectedTimeoutContext.dispose();
|
|
260
274
|
this._changeState(ConnectionState.ABORTING);
|
|
261
275
|
if (!this.closeReason) {
|
|
262
276
|
this.closeReason = err?.message;
|
|
263
277
|
}
|
|
264
278
|
await this._ctx.dispose();
|
|
265
279
|
try {
|
|
266
|
-
log("aborting protocol... ", {
|
|
267
|
-
proto: this._protocol
|
|
268
|
-
}, {
|
|
280
|
+
log("aborting protocol... ", void 0, {
|
|
269
281
|
F: __dxlog_file,
|
|
270
|
-
L:
|
|
282
|
+
L: 258,
|
|
271
283
|
S: this,
|
|
272
284
|
C: (f, a) => f(...a)
|
|
273
285
|
});
|
|
@@ -275,7 +287,7 @@ var Connection = class {
|
|
|
275
287
|
} catch (err2) {
|
|
276
288
|
log.catch(err2, void 0, {
|
|
277
289
|
F: __dxlog_file,
|
|
278
|
-
L:
|
|
290
|
+
L: 261,
|
|
279
291
|
S: this,
|
|
280
292
|
C: (f, a) => f(...a)
|
|
281
293
|
});
|
|
@@ -285,7 +297,7 @@ var Connection = class {
|
|
|
285
297
|
} catch (err2) {
|
|
286
298
|
log.catch(err2, void 0, {
|
|
287
299
|
F: __dxlog_file,
|
|
288
|
-
L:
|
|
300
|
+
L: 268,
|
|
289
301
|
S: this,
|
|
290
302
|
C: (f, a) => f(...a)
|
|
291
303
|
});
|
|
@@ -295,7 +307,7 @@ var Connection = class {
|
|
|
295
307
|
} catch (err2) {
|
|
296
308
|
log.catch(err2, void 0, {
|
|
297
309
|
F: __dxlog_file,
|
|
298
|
-
L:
|
|
310
|
+
L: 274,
|
|
299
311
|
S: this,
|
|
300
312
|
C: (f, a) => f(...a)
|
|
301
313
|
});
|
|
@@ -305,18 +317,21 @@ var Connection = class {
|
|
|
305
317
|
async close(err) {
|
|
306
318
|
if (!this.closeReason) {
|
|
307
319
|
this.closeReason = err?.message;
|
|
320
|
+
} else {
|
|
321
|
+
this.closeReason += `; ${err?.message}`;
|
|
308
322
|
}
|
|
309
323
|
if (this._state === ConnectionState.CLOSED || this._state === ConnectionState.ABORTING || this._state === ConnectionState.ABORTED) {
|
|
310
324
|
return;
|
|
311
325
|
}
|
|
312
326
|
const lastState = this._state;
|
|
313
327
|
this._changeState(ConnectionState.CLOSING);
|
|
328
|
+
await this.connectedTimeoutContext.dispose();
|
|
314
329
|
await this._ctx.dispose();
|
|
315
330
|
log("closing...", {
|
|
316
331
|
peerId: this.ownId
|
|
317
332
|
}, {
|
|
318
333
|
F: __dxlog_file,
|
|
319
|
-
L:
|
|
334
|
+
L: 299,
|
|
320
335
|
S: this,
|
|
321
336
|
C: (f, a) => f(...a)
|
|
322
337
|
});
|
|
@@ -326,7 +341,7 @@ var Connection = class {
|
|
|
326
341
|
} catch (err2) {
|
|
327
342
|
log.catch(err2, void 0, {
|
|
328
343
|
F: __dxlog_file,
|
|
329
|
-
L:
|
|
344
|
+
L: 306,
|
|
330
345
|
S: this,
|
|
331
346
|
C: (f, a) => f(...a)
|
|
332
347
|
});
|
|
@@ -336,7 +351,7 @@ var Connection = class {
|
|
|
336
351
|
} catch (err2) {
|
|
337
352
|
log.catch(err2, void 0, {
|
|
338
353
|
F: __dxlog_file,
|
|
339
|
-
L:
|
|
354
|
+
L: 313,
|
|
340
355
|
S: this,
|
|
341
356
|
C: (f, a) => f(...a)
|
|
342
357
|
});
|
|
@@ -346,7 +361,7 @@ var Connection = class {
|
|
|
346
361
|
peerId: this.ownId
|
|
347
362
|
}, {
|
|
348
363
|
F: __dxlog_file,
|
|
349
|
-
L:
|
|
364
|
+
L: 317,
|
|
350
365
|
S: this,
|
|
351
366
|
C: (f, a) => f(...a)
|
|
352
367
|
});
|
|
@@ -382,14 +397,14 @@ var Connection = class {
|
|
|
382
397
|
}
|
|
383
398
|
});
|
|
384
399
|
} catch (err) {
|
|
385
|
-
if (err instanceof CancelledError) {
|
|
400
|
+
if (err instanceof CancelledError || err instanceof Error && err.message?.includes("CANCELLED")) {
|
|
386
401
|
return;
|
|
387
402
|
}
|
|
388
403
|
log.warn("signal failed", {
|
|
389
404
|
err
|
|
390
405
|
}, {
|
|
391
406
|
F: __dxlog_file,
|
|
392
|
-
L:
|
|
407
|
+
L: 355,
|
|
393
408
|
S: this,
|
|
394
409
|
C: (f, a) => f(...a)
|
|
395
410
|
});
|
|
@@ -402,7 +417,7 @@ var Connection = class {
|
|
|
402
417
|
async signal(msg) {
|
|
403
418
|
invariant(msg.sessionId, void 0, {
|
|
404
419
|
F: __dxlog_file,
|
|
405
|
-
L:
|
|
420
|
+
L: 364,
|
|
406
421
|
S: this,
|
|
407
422
|
A: [
|
|
408
423
|
"msg.sessionId",
|
|
@@ -412,7 +427,7 @@ var Connection = class {
|
|
|
412
427
|
if (!msg.sessionId.equals(this.sessionId)) {
|
|
413
428
|
log("dropping signal for incorrect session id", void 0, {
|
|
414
429
|
F: __dxlog_file,
|
|
415
|
-
L:
|
|
430
|
+
L: 366,
|
|
416
431
|
S: this,
|
|
417
432
|
C: (f, a) => f(...a)
|
|
418
433
|
});
|
|
@@ -420,7 +435,7 @@ var Connection = class {
|
|
|
420
435
|
}
|
|
421
436
|
invariant(msg.data.signal || msg.data.signalBatch, void 0, {
|
|
422
437
|
F: __dxlog_file,
|
|
423
|
-
L:
|
|
438
|
+
L: 369,
|
|
424
439
|
S: this,
|
|
425
440
|
A: [
|
|
426
441
|
"msg.data.signal || msg.data.signalBatch",
|
|
@@ -429,7 +444,7 @@ var Connection = class {
|
|
|
429
444
|
});
|
|
430
445
|
invariant(msg.author?.equals(this.remoteId), void 0, {
|
|
431
446
|
F: __dxlog_file,
|
|
432
|
-
L:
|
|
447
|
+
L: 370,
|
|
433
448
|
S: this,
|
|
434
449
|
A: [
|
|
435
450
|
"msg.author?.equals(this.remoteId)",
|
|
@@ -438,7 +453,7 @@ var Connection = class {
|
|
|
438
453
|
});
|
|
439
454
|
invariant(msg.recipient?.equals(this.ownId), void 0, {
|
|
440
455
|
F: __dxlog_file,
|
|
441
|
-
L:
|
|
456
|
+
L: 371,
|
|
442
457
|
S: this,
|
|
443
458
|
A: [
|
|
444
459
|
"msg.recipient?.equals(this.ownId)",
|
|
@@ -462,7 +477,7 @@ var Connection = class {
|
|
|
462
477
|
msg: msg.data
|
|
463
478
|
}, {
|
|
464
479
|
F: __dxlog_file,
|
|
465
|
-
L:
|
|
480
|
+
L: 380,
|
|
466
481
|
S: this,
|
|
467
482
|
C: (f, a) => f(...a)
|
|
468
483
|
});
|
|
@@ -470,7 +485,7 @@ var Connection = class {
|
|
|
470
485
|
} else {
|
|
471
486
|
invariant(this._transport, "Connection not ready to accept signals.", {
|
|
472
487
|
F: __dxlog_file,
|
|
473
|
-
L:
|
|
488
|
+
L: 383,
|
|
474
489
|
S: this,
|
|
475
490
|
A: [
|
|
476
491
|
"this._transport",
|
|
@@ -483,7 +498,7 @@ var Connection = class {
|
|
|
483
498
|
msg: msg.data
|
|
484
499
|
}, {
|
|
485
500
|
F: __dxlog_file,
|
|
486
|
-
L:
|
|
501
|
+
L: 384,
|
|
487
502
|
S: this,
|
|
488
503
|
C: (f, a) => f(...a)
|
|
489
504
|
});
|
|
@@ -501,13 +516,13 @@ var Connection = class {
|
|
|
501
516
|
peerId: this.ownId
|
|
502
517
|
}, {
|
|
503
518
|
F: __dxlog_file,
|
|
504
|
-
L:
|
|
519
|
+
L: 395,
|
|
505
520
|
S: this,
|
|
506
521
|
C: (f, a) => f(...a)
|
|
507
522
|
});
|
|
508
523
|
invariant(state !== this._state, "Already in this state.", {
|
|
509
524
|
F: __dxlog_file,
|
|
510
|
-
L:
|
|
525
|
+
L: 396,
|
|
511
526
|
S: this,
|
|
512
527
|
A: [
|
|
513
528
|
"state !== this._state",
|
|
@@ -532,7 +547,7 @@ import { PublicKey as PublicKey2 } from "@dxos/keys";
|
|
|
532
547
|
import { log as log2 } from "@dxos/log";
|
|
533
548
|
import { schema } from "@dxos/protocols";
|
|
534
549
|
import { ComplexMap } from "@dxos/util";
|
|
535
|
-
var __dxlog_file2 = "/
|
|
550
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/signal/swarm-messenger.ts";
|
|
536
551
|
var SwarmMessage = schema.getCodecForType("dxos.mesh.swarm.SwarmMessage");
|
|
537
552
|
var SwarmMessenger = class {
|
|
538
553
|
constructor({ sendMessage, onSignal, onOffer, topic }) {
|
|
@@ -758,7 +773,7 @@ var SwarmMessenger = class {
|
|
|
758
773
|
};
|
|
759
774
|
|
|
760
775
|
// packages/core/mesh/network-manager/src/swarm/swarm.ts
|
|
761
|
-
import { Event as Event3, scheduleTask as
|
|
776
|
+
import { Event as Event3, scheduleTask as scheduleTask3, sleep as sleep2, synchronized as synchronized3 } from "@dxos/async";
|
|
762
777
|
import { Context as Context4 } from "@dxos/context";
|
|
763
778
|
import { ErrorStream as ErrorStream2 } from "@dxos/debug";
|
|
764
779
|
import { invariant as invariant4 } from "@dxos/invariant";
|
|
@@ -768,12 +783,12 @@ import { trace as trace2 } from "@dxos/protocols";
|
|
|
768
783
|
import { ComplexMap as ComplexMap2, isNotNullOrUndefined } from "@dxos/util";
|
|
769
784
|
|
|
770
785
|
// packages/core/mesh/network-manager/src/swarm/peer.ts
|
|
771
|
-
import { Event as Event2, scheduleTask, synchronized as synchronized2 } from "@dxos/async";
|
|
786
|
+
import { Event as Event2, scheduleTask as scheduleTask2, synchronized as synchronized2 } from "@dxos/async";
|
|
772
787
|
import { Context as Context3 } from "@dxos/context";
|
|
773
788
|
import { invariant as invariant3 } from "@dxos/invariant";
|
|
774
789
|
import { PublicKey as PublicKey3 } from "@dxos/keys";
|
|
775
790
|
import { log as log3 } from "@dxos/log";
|
|
776
|
-
import { CancelledError as CancelledError2, SystemError
|
|
791
|
+
import { CancelledError as CancelledError2, SystemError } from "@dxos/protocols";
|
|
777
792
|
function _ts_decorate2(decorators, target, key, desc) {
|
|
778
793
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
779
794
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -784,7 +799,7 @@ function _ts_decorate2(decorators, target, key, desc) {
|
|
|
784
799
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
785
800
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
786
801
|
}
|
|
787
|
-
var __dxlog_file3 = "/
|
|
802
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/peer.ts";
|
|
788
803
|
var ConnectionDisplacedError = class extends SystemError {
|
|
789
804
|
constructor() {
|
|
790
805
|
super("Connection displaced by remote initiator.");
|
|
@@ -816,11 +831,12 @@ var Peer = class {
|
|
|
816
831
|
const remoteId = message.author;
|
|
817
832
|
if (this.connection && ![
|
|
818
833
|
ConnectionState.CREATED,
|
|
819
|
-
ConnectionState.INITIAL
|
|
834
|
+
ConnectionState.INITIAL,
|
|
835
|
+
ConnectionState.CONNECTING
|
|
820
836
|
].includes(this.connection.state)) {
|
|
821
837
|
log3.info(`received offer when connection already in ${this.connection.state} state`, void 0, {
|
|
822
838
|
F: __dxlog_file3,
|
|
823
|
-
L:
|
|
839
|
+
L: 115,
|
|
824
840
|
S: this,
|
|
825
841
|
C: (f, a) => f(...a)
|
|
826
842
|
});
|
|
@@ -837,7 +853,7 @@ var Peer = class {
|
|
|
837
853
|
sessionId: this.connection?.sessionId
|
|
838
854
|
}, {
|
|
839
855
|
F: __dxlog_file3,
|
|
840
|
-
L:
|
|
856
|
+
L: 124,
|
|
841
857
|
S: this,
|
|
842
858
|
C: (f, a) => f(...a)
|
|
843
859
|
});
|
|
@@ -854,7 +870,7 @@ var Peer = class {
|
|
|
854
870
|
if (!this.connection) {
|
|
855
871
|
invariant3(message.sessionId, void 0, {
|
|
856
872
|
F: __dxlog_file3,
|
|
857
|
-
L:
|
|
873
|
+
L: 144,
|
|
858
874
|
S: this,
|
|
859
875
|
A: [
|
|
860
876
|
"message.sessionId",
|
|
@@ -875,7 +891,7 @@ var Peer = class {
|
|
|
875
891
|
err
|
|
876
892
|
}, {
|
|
877
893
|
F: __dxlog_file3,
|
|
878
|
-
L:
|
|
894
|
+
L: 154,
|
|
879
895
|
S: this,
|
|
880
896
|
C: (f, a) => f(...a)
|
|
881
897
|
});
|
|
@@ -897,7 +913,7 @@ var Peer = class {
|
|
|
897
913
|
async initiateConnection() {
|
|
898
914
|
invariant3(!this.initiating, "Initiation in progress.", {
|
|
899
915
|
F: __dxlog_file3,
|
|
900
|
-
L:
|
|
916
|
+
L: 171,
|
|
901
917
|
S: this,
|
|
902
918
|
A: [
|
|
903
919
|
"!this.initiating",
|
|
@@ -906,7 +922,7 @@ var Peer = class {
|
|
|
906
922
|
});
|
|
907
923
|
invariant3(!this.connection, "Already connected.", {
|
|
908
924
|
F: __dxlog_file3,
|
|
909
|
-
L:
|
|
925
|
+
L: 172,
|
|
910
926
|
S: this,
|
|
911
927
|
A: [
|
|
912
928
|
"!this.connection",
|
|
@@ -921,16 +937,17 @@ var Peer = class {
|
|
|
921
937
|
sessionId
|
|
922
938
|
}, {
|
|
923
939
|
F: __dxlog_file3,
|
|
924
|
-
L:
|
|
940
|
+
L: 174,
|
|
925
941
|
S: this,
|
|
926
942
|
C: (f, a) => f(...a)
|
|
927
943
|
});
|
|
928
944
|
const connection = this._createConnection(true, sessionId);
|
|
929
945
|
this.initiating = true;
|
|
946
|
+
let answer;
|
|
930
947
|
try {
|
|
931
948
|
await this._connectionLimiter.connecting(sessionId);
|
|
932
949
|
connection.initiate();
|
|
933
|
-
|
|
950
|
+
answer = await this._signalMessaging.offer({
|
|
934
951
|
author: this.localPeerId,
|
|
935
952
|
recipient: this.id,
|
|
936
953
|
sessionId,
|
|
@@ -946,46 +963,87 @@ var Peer = class {
|
|
|
946
963
|
remoteId: this.id
|
|
947
964
|
}, {
|
|
948
965
|
F: __dxlog_file3,
|
|
949
|
-
L:
|
|
966
|
+
L: 191,
|
|
950
967
|
S: this,
|
|
951
968
|
C: (f, a) => f(...a)
|
|
952
969
|
});
|
|
953
970
|
if (connection.state !== ConnectionState.INITIAL) {
|
|
954
971
|
log3("ignoring response", void 0, {
|
|
955
972
|
F: __dxlog_file3,
|
|
956
|
-
L:
|
|
973
|
+
L: 193,
|
|
957
974
|
S: this,
|
|
958
975
|
C: (f, a) => f(...a)
|
|
959
976
|
});
|
|
960
977
|
return;
|
|
961
978
|
}
|
|
979
|
+
} catch (err) {
|
|
980
|
+
log3("initiation error: send offer", {
|
|
981
|
+
err,
|
|
982
|
+
topic: this.topic,
|
|
983
|
+
peerId: this.localPeerId,
|
|
984
|
+
remoteId: this.id
|
|
985
|
+
}, {
|
|
986
|
+
F: __dxlog_file3,
|
|
987
|
+
L: 197,
|
|
988
|
+
S: this,
|
|
989
|
+
C: (f, a) => f(...a)
|
|
990
|
+
});
|
|
991
|
+
await connection.abort(err);
|
|
992
|
+
throw err;
|
|
993
|
+
} finally {
|
|
994
|
+
this.initiating = false;
|
|
995
|
+
}
|
|
996
|
+
try {
|
|
962
997
|
if (!answer.accept) {
|
|
963
998
|
this._callbacks.onRejected();
|
|
964
999
|
return;
|
|
965
1000
|
}
|
|
1001
|
+
} catch (err) {
|
|
1002
|
+
log3("initiation error: accept answer", {
|
|
1003
|
+
err,
|
|
1004
|
+
topic: this.topic,
|
|
1005
|
+
peerId: this.localPeerId,
|
|
1006
|
+
remoteId: this.id
|
|
1007
|
+
}, {
|
|
1008
|
+
F: __dxlog_file3,
|
|
1009
|
+
L: 210,
|
|
1010
|
+
S: this,
|
|
1011
|
+
C: (f, a) => f(...a)
|
|
1012
|
+
});
|
|
1013
|
+
await connection.abort(err);
|
|
1014
|
+
throw err;
|
|
1015
|
+
} finally {
|
|
1016
|
+
this.initiating = false;
|
|
1017
|
+
}
|
|
1018
|
+
try {
|
|
1019
|
+
log3("opening connection as initiator", void 0, {
|
|
1020
|
+
F: __dxlog_file3,
|
|
1021
|
+
L: 223,
|
|
1022
|
+
S: this,
|
|
1023
|
+
C: (f, a) => f(...a)
|
|
1024
|
+
});
|
|
966
1025
|
await connection.openConnection();
|
|
967
1026
|
this._callbacks.onAccepted();
|
|
968
1027
|
} catch (err) {
|
|
969
|
-
log3("initiation error", {
|
|
1028
|
+
log3("initiation error: open connection", {
|
|
970
1029
|
err,
|
|
971
1030
|
topic: this.topic,
|
|
972
1031
|
peerId: this.localPeerId,
|
|
973
1032
|
remoteId: this.id
|
|
974
1033
|
}, {
|
|
975
1034
|
F: __dxlog_file3,
|
|
976
|
-
L:
|
|
1035
|
+
L: 227,
|
|
1036
|
+
S: this,
|
|
1037
|
+
C: (f, a) => f(...a)
|
|
1038
|
+
});
|
|
1039
|
+
log3.warn("closing connection due to unhandled error on openConnection", {
|
|
1040
|
+
err
|
|
1041
|
+
}, {
|
|
1042
|
+
F: __dxlog_file3,
|
|
1043
|
+
L: 234,
|
|
977
1044
|
S: this,
|
|
978
1045
|
C: (f, a) => f(...a)
|
|
979
1046
|
});
|
|
980
|
-
if (err instanceof TimeoutError) {
|
|
981
|
-
log3.warn("aborting connection due to signalling failure", void 0, {
|
|
982
|
-
F: __dxlog_file3,
|
|
983
|
-
L: 202,
|
|
984
|
-
S: this,
|
|
985
|
-
C: (f, a) => f(...a)
|
|
986
|
-
});
|
|
987
|
-
await connection.abort(err);
|
|
988
|
-
}
|
|
989
1047
|
await this.closeConnection(err);
|
|
990
1048
|
throw err;
|
|
991
1049
|
} finally {
|
|
@@ -1005,13 +1063,13 @@ var Peer = class {
|
|
|
1005
1063
|
sessionId
|
|
1006
1064
|
}, {
|
|
1007
1065
|
F: __dxlog_file3,
|
|
1008
|
-
L:
|
|
1066
|
+
L: 248,
|
|
1009
1067
|
S: this,
|
|
1010
1068
|
C: (f, a) => f(...a)
|
|
1011
1069
|
});
|
|
1012
1070
|
invariant3(!this.connection, "Already connected.", {
|
|
1013
1071
|
F: __dxlog_file3,
|
|
1014
|
-
L:
|
|
1072
|
+
L: 255,
|
|
1015
1073
|
S: this,
|
|
1016
1074
|
A: [
|
|
1017
1075
|
"!this.connection",
|
|
@@ -1047,7 +1105,7 @@ var Peer = class {
|
|
|
1047
1105
|
initiator
|
|
1048
1106
|
}, {
|
|
1049
1107
|
F: __dxlog_file3,
|
|
1050
|
-
L:
|
|
1108
|
+
L: 274,
|
|
1051
1109
|
S: this,
|
|
1052
1110
|
C: (f, a) => f(...a)
|
|
1053
1111
|
});
|
|
@@ -1060,14 +1118,14 @@ var Peer = class {
|
|
|
1060
1118
|
initiator
|
|
1061
1119
|
}, {
|
|
1062
1120
|
F: __dxlog_file3,
|
|
1063
|
-
L:
|
|
1121
|
+
L: 283,
|
|
1064
1122
|
S: this,
|
|
1065
1123
|
C: (f, a) => f(...a)
|
|
1066
1124
|
});
|
|
1067
1125
|
this._connectionLimiter.doneConnecting(sessionId);
|
|
1068
1126
|
invariant3(this.connection === connection, "Connection mismatch (race condition).", {
|
|
1069
1127
|
F: __dxlog_file3,
|
|
1070
|
-
L:
|
|
1128
|
+
L: 288,
|
|
1071
1129
|
S: this,
|
|
1072
1130
|
A: [
|
|
1073
1131
|
"this.connection === connection",
|
|
@@ -1082,7 +1140,7 @@ var Peer = class {
|
|
|
1082
1140
|
initiator
|
|
1083
1141
|
}, {
|
|
1084
1142
|
F: __dxlog_file3,
|
|
1085
|
-
L:
|
|
1143
|
+
L: 290,
|
|
1086
1144
|
S: this,
|
|
1087
1145
|
C: (f, a) => f(...a)
|
|
1088
1146
|
});
|
|
@@ -1096,7 +1154,7 @@ var Peer = class {
|
|
|
1096
1154
|
this._availableAfter = increaseInterval(this._availableAfter);
|
|
1097
1155
|
}
|
|
1098
1156
|
this._callbacks.onDisconnected();
|
|
1099
|
-
|
|
1157
|
+
scheduleTask2(this._connectionCtx, () => {
|
|
1100
1158
|
this.availableToConnect = true;
|
|
1101
1159
|
this._callbacks.onPeerAvailable();
|
|
1102
1160
|
}, this._availableAfter);
|
|
@@ -1109,7 +1167,7 @@ var Peer = class {
|
|
|
1109
1167
|
void this._connectionCtx?.dispose();
|
|
1110
1168
|
this._connectionCtx = this._ctx.derive();
|
|
1111
1169
|
connection.errors.handle((err) => {
|
|
1112
|
-
log3.warn("connection error", {
|
|
1170
|
+
log3.warn("connection error, closing", {
|
|
1113
1171
|
topic: this.topic,
|
|
1114
1172
|
peerId: this.localPeerId,
|
|
1115
1173
|
remoteId: this.id,
|
|
@@ -1117,7 +1175,7 @@ var Peer = class {
|
|
|
1117
1175
|
err
|
|
1118
1176
|
}, {
|
|
1119
1177
|
F: __dxlog_file3,
|
|
1120
|
-
L:
|
|
1178
|
+
L: 330,
|
|
1121
1179
|
S: this,
|
|
1122
1180
|
C: (f, a) => f(...a)
|
|
1123
1181
|
});
|
|
@@ -1130,7 +1188,7 @@ var Peer = class {
|
|
|
1130
1188
|
err
|
|
1131
1189
|
}, {
|
|
1132
1190
|
F: __dxlog_file3,
|
|
1133
|
-
L:
|
|
1191
|
+
L: 337,
|
|
1134
1192
|
S: this,
|
|
1135
1193
|
C: (f, a) => f(...a)
|
|
1136
1194
|
});
|
|
@@ -1149,7 +1207,7 @@ var Peer = class {
|
|
|
1149
1207
|
sessionId: connection.sessionId
|
|
1150
1208
|
}, {
|
|
1151
1209
|
F: __dxlog_file3,
|
|
1152
|
-
L:
|
|
1210
|
+
L: 362,
|
|
1153
1211
|
S: this,
|
|
1154
1212
|
C: (f, a) => f(...a)
|
|
1155
1213
|
});
|
|
@@ -1159,7 +1217,7 @@ var Peer = class {
|
|
|
1159
1217
|
sessionId: connection.sessionId
|
|
1160
1218
|
}, {
|
|
1161
1219
|
F: __dxlog_file3,
|
|
1162
|
-
L:
|
|
1220
|
+
L: 368,
|
|
1163
1221
|
S: this,
|
|
1164
1222
|
C: (f, a) => f(...a)
|
|
1165
1223
|
});
|
|
@@ -1170,7 +1228,7 @@ var Peer = class {
|
|
|
1170
1228
|
message
|
|
1171
1229
|
}, {
|
|
1172
1230
|
F: __dxlog_file3,
|
|
1173
|
-
L:
|
|
1231
|
+
L: 373,
|
|
1174
1232
|
S: this,
|
|
1175
1233
|
C: (f, a) => f(...a)
|
|
1176
1234
|
});
|
|
@@ -1178,18 +1236,18 @@ var Peer = class {
|
|
|
1178
1236
|
}
|
|
1179
1237
|
await this.connection.signal(message);
|
|
1180
1238
|
}
|
|
1181
|
-
async destroy() {
|
|
1239
|
+
async destroy(reason) {
|
|
1182
1240
|
await this._ctx.dispose();
|
|
1183
1241
|
log3("Destroying peer", {
|
|
1184
1242
|
peerId: this.id,
|
|
1185
1243
|
topic: this.topic
|
|
1186
1244
|
}, {
|
|
1187
1245
|
F: __dxlog_file3,
|
|
1188
|
-
L:
|
|
1246
|
+
L: 383,
|
|
1189
1247
|
S: this,
|
|
1190
1248
|
C: (f, a) => f(...a)
|
|
1191
1249
|
});
|
|
1192
|
-
await this?.connection?.close();
|
|
1250
|
+
await this?.connection?.close(reason);
|
|
1193
1251
|
}
|
|
1194
1252
|
};
|
|
1195
1253
|
_ts_decorate2([
|
|
@@ -1219,7 +1277,7 @@ function _ts_decorate3(decorators, target, key, desc) {
|
|
|
1219
1277
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1220
1278
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1221
1279
|
}
|
|
1222
|
-
var __dxlog_file4 = "/
|
|
1280
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/swarm.ts";
|
|
1223
1281
|
var INITIATION_DELAY = 100;
|
|
1224
1282
|
var getClassName = (obj) => Object.getPrototypeOf(obj).constructor.name;
|
|
1225
1283
|
var Swarm = class {
|
|
@@ -1330,7 +1388,7 @@ var Swarm = class {
|
|
|
1330
1388
|
this._listeningHandle = void 0;
|
|
1331
1389
|
await this._ctx.dispose();
|
|
1332
1390
|
await this._topology.destroy();
|
|
1333
|
-
await Promise.all(Array.from(this._peers.keys()).map((key) => this._destroyPeer(key)));
|
|
1391
|
+
await Promise.all(Array.from(this._peers.keys()).map((key) => this._destroyPeer(key, "swarm destroyed")));
|
|
1334
1392
|
log4("destroyed", void 0, {
|
|
1335
1393
|
F: __dxlog_file4,
|
|
1336
1394
|
L: 148,
|
|
@@ -1402,13 +1460,22 @@ var Swarm = class {
|
|
|
1402
1460
|
if (peer) {
|
|
1403
1461
|
peer.advertizing = false;
|
|
1404
1462
|
if (peer.connection?.state !== ConnectionState.CONNECTED) {
|
|
1405
|
-
void this._destroyPeer(peer.id).catch((err) => log4.catch(err, void 0, {
|
|
1463
|
+
void this._destroyPeer(peer.id, "peer left").catch((err) => log4.catch(err, void 0, {
|
|
1406
1464
|
F: __dxlog_file4,
|
|
1407
1465
|
L: 189,
|
|
1408
1466
|
S: this,
|
|
1409
1467
|
C: (f, a) => f(...a)
|
|
1410
1468
|
}));
|
|
1411
1469
|
}
|
|
1470
|
+
} else {
|
|
1471
|
+
log4("received peerLeft but no peer found", {
|
|
1472
|
+
peer: swarmEvent.peerLeft.peer
|
|
1473
|
+
}, {
|
|
1474
|
+
F: __dxlog_file4,
|
|
1475
|
+
L: 192,
|
|
1476
|
+
S: this,
|
|
1477
|
+
C: (f, a) => f(...a)
|
|
1478
|
+
});
|
|
1412
1479
|
}
|
|
1413
1480
|
}
|
|
1414
1481
|
this._topology.update();
|
|
@@ -1418,14 +1485,14 @@ var Swarm = class {
|
|
|
1418
1485
|
message
|
|
1419
1486
|
}, {
|
|
1420
1487
|
F: __dxlog_file4,
|
|
1421
|
-
L:
|
|
1488
|
+
L: 201,
|
|
1422
1489
|
S: this,
|
|
1423
1490
|
C: (f, a) => f(...a)
|
|
1424
1491
|
});
|
|
1425
1492
|
if (this._ctx.disposed) {
|
|
1426
1493
|
log4("ignored for disposed swarm", void 0, {
|
|
1427
1494
|
F: __dxlog_file4,
|
|
1428
|
-
L:
|
|
1495
|
+
L: 203,
|
|
1429
1496
|
S: this,
|
|
1430
1497
|
C: (f, a) => f(...a)
|
|
1431
1498
|
});
|
|
@@ -1435,7 +1502,7 @@ var Swarm = class {
|
|
|
1435
1502
|
}
|
|
1436
1503
|
invariant4(message.author, void 0, {
|
|
1437
1504
|
F: __dxlog_file4,
|
|
1438
|
-
L:
|
|
1505
|
+
L: 208,
|
|
1439
1506
|
S: this,
|
|
1440
1507
|
A: [
|
|
1441
1508
|
"message.author",
|
|
@@ -1447,7 +1514,7 @@ var Swarm = class {
|
|
|
1447
1514
|
message
|
|
1448
1515
|
}, {
|
|
1449
1516
|
F: __dxlog_file4,
|
|
1450
|
-
L:
|
|
1517
|
+
L: 210,
|
|
1451
1518
|
S: this,
|
|
1452
1519
|
C: (f, a) => f(...a)
|
|
1453
1520
|
});
|
|
@@ -1460,7 +1527,7 @@ var Swarm = class {
|
|
|
1460
1527
|
message
|
|
1461
1528
|
}, {
|
|
1462
1529
|
F: __dxlog_file4,
|
|
1463
|
-
L:
|
|
1530
|
+
L: 214,
|
|
1464
1531
|
S: this,
|
|
1465
1532
|
C: (f, a) => f(...a)
|
|
1466
1533
|
});
|
|
@@ -1478,14 +1545,14 @@ var Swarm = class {
|
|
|
1478
1545
|
message
|
|
1479
1546
|
}, {
|
|
1480
1547
|
F: __dxlog_file4,
|
|
1481
|
-
L:
|
|
1548
|
+
L: 225,
|
|
1482
1549
|
S: this,
|
|
1483
1550
|
C: (f, a) => f(...a)
|
|
1484
1551
|
});
|
|
1485
1552
|
if (this._ctx.disposed) {
|
|
1486
1553
|
log4.info("ignored for offline swarm", void 0, {
|
|
1487
1554
|
F: __dxlog_file4,
|
|
1488
|
-
L:
|
|
1555
|
+
L: 227,
|
|
1489
1556
|
S: this,
|
|
1490
1557
|
C: (f, a) => f(...a)
|
|
1491
1558
|
});
|
|
@@ -1493,7 +1560,7 @@ var Swarm = class {
|
|
|
1493
1560
|
}
|
|
1494
1561
|
invariant4(message.recipient?.equals(this._ownPeerId), `Invalid signal peer id expected=${this.ownPeerId}, actual=${message.recipient}`, {
|
|
1495
1562
|
F: __dxlog_file4,
|
|
1496
|
-
L:
|
|
1563
|
+
L: 230,
|
|
1497
1564
|
S: this,
|
|
1498
1565
|
A: [
|
|
1499
1566
|
"message.recipient?.equals(this._ownPeerId)",
|
|
@@ -1502,7 +1569,7 @@ var Swarm = class {
|
|
|
1502
1569
|
});
|
|
1503
1570
|
invariant4(message.topic?.equals(this._topic), void 0, {
|
|
1504
1571
|
F: __dxlog_file4,
|
|
1505
|
-
L:
|
|
1572
|
+
L: 234,
|
|
1506
1573
|
S: this,
|
|
1507
1574
|
A: [
|
|
1508
1575
|
"message.topic?.equals(this._topic)",
|
|
@@ -1511,7 +1578,7 @@ var Swarm = class {
|
|
|
1511
1578
|
});
|
|
1512
1579
|
invariant4(message.author, void 0, {
|
|
1513
1580
|
F: __dxlog_file4,
|
|
1514
|
-
L:
|
|
1581
|
+
L: 235,
|
|
1515
1582
|
S: this,
|
|
1516
1583
|
A: [
|
|
1517
1584
|
"message.author",
|
|
@@ -1526,7 +1593,7 @@ var Swarm = class {
|
|
|
1526
1593
|
await this._ctx.dispose();
|
|
1527
1594
|
await Promise.all([
|
|
1528
1595
|
...this._peers.keys()
|
|
1529
|
-
].map((peerId) => this._destroyPeer(peerId)));
|
|
1596
|
+
].map((peerId) => this._destroyPeer(peerId, "goOffline")));
|
|
1530
1597
|
}
|
|
1531
1598
|
// For debug purposes
|
|
1532
1599
|
async goOnline() {
|
|
@@ -1544,14 +1611,22 @@ var Swarm = class {
|
|
|
1544
1611
|
},
|
|
1545
1612
|
onDisconnected: async () => {
|
|
1546
1613
|
if (!peer.advertizing) {
|
|
1547
|
-
await this._destroyPeer(peer.id);
|
|
1614
|
+
await this._destroyPeer(peer.id, "peer disconnected");
|
|
1548
1615
|
}
|
|
1549
1616
|
this.disconnected.emit(peerId);
|
|
1550
1617
|
this._topology.update();
|
|
1551
1618
|
},
|
|
1552
1619
|
onRejected: () => {
|
|
1553
1620
|
if (this._peers.has(peerId)) {
|
|
1554
|
-
|
|
1621
|
+
log4("peer rejected connection", {
|
|
1622
|
+
peerId
|
|
1623
|
+
}, {
|
|
1624
|
+
F: __dxlog_file4,
|
|
1625
|
+
L: 284,
|
|
1626
|
+
S: this,
|
|
1627
|
+
C: (f, a) => f(...a)
|
|
1628
|
+
});
|
|
1629
|
+
void this._destroyPeer(peerId, "peer rejected connection");
|
|
1555
1630
|
}
|
|
1556
1631
|
},
|
|
1557
1632
|
onAccepted: () => {
|
|
@@ -1568,17 +1643,17 @@ var Swarm = class {
|
|
|
1568
1643
|
}
|
|
1569
1644
|
return peer;
|
|
1570
1645
|
}
|
|
1571
|
-
async _destroyPeer(peerId) {
|
|
1646
|
+
async _destroyPeer(peerId, reason) {
|
|
1572
1647
|
invariant4(this._peers.has(peerId), void 0, {
|
|
1573
1648
|
F: __dxlog_file4,
|
|
1574
|
-
L:
|
|
1649
|
+
L: 306,
|
|
1575
1650
|
S: this,
|
|
1576
1651
|
A: [
|
|
1577
1652
|
"this._peers.has(peerId)",
|
|
1578
1653
|
""
|
|
1579
1654
|
]
|
|
1580
1655
|
});
|
|
1581
|
-
await this._peers.get(peerId).destroy();
|
|
1656
|
+
await this._peers.get(peerId).destroy(new Error(reason));
|
|
1582
1657
|
this._peers.delete(peerId);
|
|
1583
1658
|
}
|
|
1584
1659
|
_getSwarmController() {
|
|
@@ -1592,13 +1667,13 @@ var Swarm = class {
|
|
|
1592
1667
|
if (this._ctx.disposed) {
|
|
1593
1668
|
return;
|
|
1594
1669
|
}
|
|
1595
|
-
|
|
1670
|
+
scheduleTask3(this._ctx, async () => {
|
|
1596
1671
|
try {
|
|
1597
1672
|
await this._initiateConnection(peer);
|
|
1598
1673
|
} catch (err) {
|
|
1599
1674
|
log4("initiation error", err, {
|
|
1600
1675
|
F: __dxlog_file4,
|
|
1601
|
-
L:
|
|
1676
|
+
L: 332,
|
|
1602
1677
|
S: this,
|
|
1603
1678
|
C: (f, a) => f(...a)
|
|
1604
1679
|
});
|
|
@@ -1609,7 +1684,7 @@ var Swarm = class {
|
|
|
1609
1684
|
if (this._ctx.disposed) {
|
|
1610
1685
|
return;
|
|
1611
1686
|
}
|
|
1612
|
-
|
|
1687
|
+
scheduleTask3(this._ctx, async () => {
|
|
1613
1688
|
await this._closeConnection(peer);
|
|
1614
1689
|
this._topology.update();
|
|
1615
1690
|
});
|
|
@@ -1626,7 +1701,7 @@ var Swarm = class {
|
|
|
1626
1701
|
remoteId
|
|
1627
1702
|
}, {
|
|
1628
1703
|
F: __dxlog_file4,
|
|
1629
|
-
L:
|
|
1704
|
+
L: 359,
|
|
1630
1705
|
S: this,
|
|
1631
1706
|
C: (f, a) => f(...a)
|
|
1632
1707
|
});
|
|
@@ -1643,7 +1718,7 @@ var Swarm = class {
|
|
|
1643
1718
|
remoteId
|
|
1644
1719
|
}, {
|
|
1645
1720
|
F: __dxlog_file4,
|
|
1646
|
-
L:
|
|
1721
|
+
L: 373,
|
|
1647
1722
|
S: this,
|
|
1648
1723
|
C: (f, a) => f(...a)
|
|
1649
1724
|
});
|
|
@@ -1653,7 +1728,7 @@ var Swarm = class {
|
|
|
1653
1728
|
remoteId
|
|
1654
1729
|
}, {
|
|
1655
1730
|
F: __dxlog_file4,
|
|
1656
|
-
L:
|
|
1731
|
+
L: 376,
|
|
1657
1732
|
S: this,
|
|
1658
1733
|
C: (f, a) => f(...a)
|
|
1659
1734
|
});
|
|
@@ -1693,7 +1768,7 @@ import { Event as Event4, EventSubscriptions } from "@dxos/async";
|
|
|
1693
1768
|
import { PublicKey as PublicKey5 } from "@dxos/keys";
|
|
1694
1769
|
import { log as log5 } from "@dxos/log";
|
|
1695
1770
|
import { ComplexMap as ComplexMap3 } from "@dxos/util";
|
|
1696
|
-
var __dxlog_file5 = "/
|
|
1771
|
+
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/swarm-mapper.ts";
|
|
1697
1772
|
var SwarmMapper = class {
|
|
1698
1773
|
get peers() {
|
|
1699
1774
|
return Array.from(this._peers.values());
|
|
@@ -1765,7 +1840,7 @@ import { PublicKey as PublicKey6 } from "@dxos/keys";
|
|
|
1765
1840
|
import { log as log6 } from "@dxos/log";
|
|
1766
1841
|
import { CancelledError as CancelledError3 } from "@dxos/protocols";
|
|
1767
1842
|
import { ComplexMap as ComplexMap4 } from "@dxos/util";
|
|
1768
|
-
var __dxlog_file6 = "/
|
|
1843
|
+
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/connection-limiter.ts";
|
|
1769
1844
|
var MAX_CONCURRENT_INITIATING_CONNECTIONS = 50;
|
|
1770
1845
|
var ConnectionLimiter = class {
|
|
1771
1846
|
constructor({ maxConcurrentInitConnections = MAX_CONCURRENT_INITIATING_CONNECTIONS } = {}) {
|
|
@@ -1918,7 +1993,7 @@ import { Messenger } from "@dxos/messaging";
|
|
|
1918
1993
|
import { trace as trace3 } from "@dxos/protocols";
|
|
1919
1994
|
import { ConnectionState as ConnectionState2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
1920
1995
|
import { ComplexMap as ComplexMap6 } from "@dxos/util";
|
|
1921
|
-
var __dxlog_file7 = "/
|
|
1996
|
+
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/network-manager.ts";
|
|
1922
1997
|
var NetworkManager = class {
|
|
1923
1998
|
constructor({ transportFactory, signalManager, log: log1 }) {
|
|
1924
1999
|
/**
|
|
@@ -2154,7 +2229,7 @@ var NetworkManager = class {
|
|
|
2154
2229
|
|
|
2155
2230
|
// packages/core/mesh/network-manager/src/topology/fully-connected-topology.ts
|
|
2156
2231
|
import { invariant as invariant7 } from "@dxos/invariant";
|
|
2157
|
-
var __dxlog_file8 = "/
|
|
2232
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/topology/fully-connected-topology.ts";
|
|
2158
2233
|
var FullyConnectedTopology = class {
|
|
2159
2234
|
toString() {
|
|
2160
2235
|
return "FullyConnectedTopology";
|
|
@@ -2197,7 +2272,7 @@ var FullyConnectedTopology = class {
|
|
|
2197
2272
|
import distance from "xor-distance";
|
|
2198
2273
|
import { invariant as invariant8 } from "@dxos/invariant";
|
|
2199
2274
|
import { log as log8 } from "@dxos/log";
|
|
2200
|
-
var __dxlog_file9 = "/
|
|
2275
|
+
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/topology/mmst-topology.ts";
|
|
2201
2276
|
var MMSTTopology = class {
|
|
2202
2277
|
constructor({ originateConnections = 2, maxPeers = 4, sampleSize = 10 } = {}) {
|
|
2203
2278
|
this._sampleCollected = false;
|
|
@@ -2306,7 +2381,7 @@ var sortByXorDistance = (keys, reference) => keys.sort((a, b) => distance.gt(dis
|
|
|
2306
2381
|
// packages/core/mesh/network-manager/src/topology/star-topology.ts
|
|
2307
2382
|
import { invariant as invariant9 } from "@dxos/invariant";
|
|
2308
2383
|
import { log as log9 } from "@dxos/log";
|
|
2309
|
-
var __dxlog_file10 = "/
|
|
2384
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/topology/star-topology.ts";
|
|
2310
2385
|
var StarTopology = class {
|
|
2311
2386
|
constructor(_centralPeer) {
|
|
2312
2387
|
this._centralPeer = _centralPeer;
|
|
@@ -2417,7 +2492,7 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
2417
2492
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2418
2493
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2419
2494
|
}
|
|
2420
|
-
var __dxlog_file11 = "/
|
|
2495
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/memory-transport.ts";
|
|
2421
2496
|
var MEMORY_TRANSPORT_DELAY = 1;
|
|
2422
2497
|
var createStreamDelay = (delay) => {
|
|
2423
2498
|
return new Transform({
|
|
@@ -2612,7 +2687,7 @@ try {
|
|
|
2612
2687
|
}
|
|
2613
2688
|
|
|
2614
2689
|
// packages/core/mesh/network-manager/src/transport/simplepeer-transport.ts
|
|
2615
|
-
var __dxlog_file12 = "/
|
|
2690
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/simplepeer-transport.ts";
|
|
2616
2691
|
var SimplePeerTransport = class {
|
|
2617
2692
|
constructor(params) {
|
|
2618
2693
|
this.params = params;
|
|
@@ -2801,7 +2876,7 @@ import { PublicKey as PublicKey11 } from "@dxos/keys";
|
|
|
2801
2876
|
import { log as log12 } from "@dxos/log";
|
|
2802
2877
|
import { ConnectionState as ConnectionState3 } from "@dxos/protocols/proto/dxos/mesh/bridge";
|
|
2803
2878
|
import { ComplexMap as ComplexMap8 } from "@dxos/util";
|
|
2804
|
-
var __dxlog_file13 = "/
|
|
2879
|
+
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/simplepeer-transport-service.ts";
|
|
2805
2880
|
var SimplePeerTransportService = class {
|
|
2806
2881
|
constructor(_webrtcConfig) {
|
|
2807
2882
|
this._webrtcConfig = _webrtcConfig;
|
|
@@ -2941,10 +3016,10 @@ import { ErrorStream as ErrorStream5 } from "@dxos/debug";
|
|
|
2941
3016
|
import { invariant as invariant13 } from "@dxos/invariant";
|
|
2942
3017
|
import { PublicKey as PublicKey12 } from "@dxos/keys";
|
|
2943
3018
|
import { log as log13 } from "@dxos/log";
|
|
2944
|
-
import { ConnectionResetError as ConnectionResetError3, TimeoutError
|
|
3019
|
+
import { ConnectionResetError as ConnectionResetError3, TimeoutError, ProtocolError as ProtocolError3, ConnectivityError as ConnectivityError3, UnknownProtocolError as UnknownProtocolError3 } from "@dxos/protocols";
|
|
2945
3020
|
import { ConnectionState as ConnectionState4 } from "@dxos/protocols/proto/dxos/mesh/bridge";
|
|
2946
3021
|
import { arrayToBuffer } from "@dxos/util";
|
|
2947
|
-
var __dxlog_file14 = "/
|
|
3022
|
+
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/simplepeer-transport-proxy.ts";
|
|
2948
3023
|
var SimplePeerTransportProxy = class {
|
|
2949
3024
|
constructor(_params) {
|
|
2950
3025
|
this._params = _params;
|
|
@@ -3094,7 +3169,7 @@ var decodeError = (err) => {
|
|
|
3094
3169
|
if (message.includes("CONNECTION_RESET")) {
|
|
3095
3170
|
return new ConnectionResetError3(message);
|
|
3096
3171
|
} else if (message.includes("TIMEOUT")) {
|
|
3097
|
-
return new
|
|
3172
|
+
return new TimeoutError(message);
|
|
3098
3173
|
} else if (message.includes("PROTOCOL_ERROR")) {
|
|
3099
3174
|
return new ProtocolError3(message);
|
|
3100
3175
|
} else if (message.includes("CONNECTIVITY_ERROR")) {
|
|
@@ -3121,7 +3196,7 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
3121
3196
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3122
3197
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3123
3198
|
}
|
|
3124
|
-
var __dxlog_file15 = "/
|
|
3199
|
+
var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/libdatachannel-transport.ts";
|
|
3125
3200
|
var DATACHANNEL_LABEL = "dxos.mesh.transport";
|
|
3126
3201
|
var MAX_BUFFERED_AMOUNT = 64 * 1024;
|
|
3127
3202
|
var MAX_MESSAGE_SIZE = 64 * 1024;
|
|
@@ -3514,4 +3589,4 @@ export {
|
|
|
3514
3589
|
TcpTransport,
|
|
3515
3590
|
createTeleportProtocolFactory
|
|
3516
3591
|
};
|
|
3517
|
-
//# sourceMappingURL=chunk-
|
|
3592
|
+
//# sourceMappingURL=chunk-UE5KR5PC.mjs.map
|