@dxos/network-manager 0.3.1-main.5e68e9d → 0.3.1-main.b9bb100

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.
@@ -668,7 +668,6 @@ function _ts_decorate(decorators, target, key, desc) {
668
668
  }
669
669
  var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/connection.ts";
670
670
  var STARTING_SIGNALLING_DELAY = 10;
671
- var TRANSPORT_CONNECTION_TIMEOUT = 1e4;
672
671
  var MAX_SIGNALLING_DELAY = 300;
673
672
  var ConnectionState;
674
673
  (function(ConnectionState6) {
@@ -724,7 +723,6 @@ var Connection = class {
724
723
  this._transportFactory = _transportFactory;
725
724
  this._callbacks = _callbacks;
726
725
  this._ctx = new import_context.Context();
727
- this.connectedTimeoutContext = new import_context.Context();
728
726
  this._state = ConnectionState.CREATED;
729
727
  this._incomingSignalBuffer = [];
730
728
  this._outgoingSignalBuffer = [];
@@ -743,7 +741,7 @@ var Connection = class {
743
741
  initiator: this.initiator
744
742
  }, {
745
743
  F: __dxlog_file2,
746
- L: 129,
744
+ L: 123,
747
745
  S: this,
748
746
  C: (f, a) => f(...a)
749
747
  });
@@ -763,7 +761,7 @@ var Connection = class {
763
761
  async openConnection() {
764
762
  (0, import_invariant.invariant)(this._state === ConnectionState.INITIAL, "Invalid state.", {
765
763
  F: __dxlog_file2,
766
- L: 154,
764
+ L: 148,
767
765
  S: this,
768
766
  A: [
769
767
  "this._state === ConnectionState.INITIAL",
@@ -774,7 +772,7 @@ var Connection = class {
774
772
  id: this._instanceId
775
773
  }), {
776
774
  F: __dxlog_file2,
777
- L: 155,
775
+ L: 149,
778
776
  S: this,
779
777
  C: (f, a) => f(...a)
780
778
  });
@@ -786,7 +784,7 @@ var Connection = class {
786
784
  initiator: this.initiator
787
785
  }, {
788
786
  F: __dxlog_file2,
789
- L: 156,
787
+ L: 150,
790
788
  S: this,
791
789
  C: (f, a) => f(...a)
792
790
  });
@@ -797,24 +795,15 @@ var Connection = class {
797
795
  this._protocol.stream.on("close", () => {
798
796
  (0, import_log2.log)("protocol stream closed", void 0, {
799
797
  F: __dxlog_file2,
800
- L: 173,
798
+ L: 167,
801
799
  S: this,
802
800
  C: (f, a) => f(...a)
803
801
  });
804
802
  this.close(new import_protocols.ProtocolError("protocol stream closed")).catch((err) => this.errors.raise(err));
805
803
  });
806
- (0, import_async2.scheduleTask)(this.connectedTimeoutContext, async () => {
807
- import_log2.log.warn("timeout waiting for transport to connect, aborting", void 0, {
808
- F: __dxlog_file2,
809
- L: 180,
810
- S: this,
811
- C: (f, a) => f(...a)
812
- });
813
- await this.abort().catch((err) => this.errors.raise(err));
814
- }, TRANSPORT_CONNECTION_TIMEOUT);
815
804
  (0, import_invariant.invariant)(!this._transport, void 0, {
816
805
  F: __dxlog_file2,
817
- L: 186,
806
+ L: 171,
818
807
  S: this,
819
808
  A: [
820
809
  "!this._transport",
@@ -826,27 +815,26 @@ var Connection = class {
826
815
  stream: this._protocol.stream,
827
816
  sendSignal: async (signal) => this._sendSignal(signal)
828
817
  });
829
- this._transport.connected.once(async () => {
818
+ this._transport.connected.once(() => {
830
819
  this._changeState(ConnectionState.CONNECTED);
831
- await this.connectedTimeoutContext.dispose();
832
820
  this._callbacks?.onConnected?.();
833
821
  });
834
822
  this._transport.closed.once(() => {
835
823
  this._transport = void 0;
836
824
  (0, import_log2.log)("abort triggered by transport close", void 0, {
837
825
  F: __dxlog_file2,
838
- L: 201,
826
+ L: 185,
839
827
  S: this,
840
828
  C: (f, a) => f(...a)
841
829
  });
842
830
  this.abort().catch((err) => this.errors.raise(err));
843
831
  });
844
- this._transport.errors.handle(async (err) => {
832
+ this._transport.errors.handle((err) => {
845
833
  (0, import_log2.log)("transport error:", {
846
834
  err
847
835
  }, {
848
836
  F: __dxlog_file2,
849
- L: 206,
837
+ L: 190,
850
838
  S: this,
851
839
  C: (f, a) => f(...a)
852
840
  });
@@ -856,7 +844,7 @@ var Connection = class {
856
844
  if (err instanceof import_protocols.ConnectionResetError) {
857
845
  import_log2.log.warn("aborting due to transport ConnectionResetError", void 0, {
858
846
  F: __dxlog_file2,
859
- L: 213,
847
+ L: 197,
860
848
  S: this,
861
849
  C: (f, a) => f(...a)
862
850
  });
@@ -864,7 +852,7 @@ var Connection = class {
864
852
  } else if (err instanceof import_protocols.ConnectivityError) {
865
853
  import_log2.log.warn("aborting due to transport ConnectivityError", void 0, {
866
854
  F: __dxlog_file2,
867
- L: 216,
855
+ L: 200,
868
856
  S: this,
869
857
  C: (f, a) => f(...a)
870
858
  });
@@ -874,13 +862,12 @@ var Connection = class {
874
862
  err
875
863
  }, {
876
864
  F: __dxlog_file2,
877
- L: 219,
865
+ L: 203,
878
866
  S: this,
879
867
  C: (f, a) => f(...a)
880
868
  });
881
869
  }
882
870
  if (this._state !== ConnectionState.CLOSED && this._state !== ConnectionState.CLOSING) {
883
- await this.connectedTimeoutContext.dispose();
884
871
  this.errors.raise(err);
885
872
  }
886
873
  });
@@ -892,7 +879,7 @@ var Connection = class {
892
879
  id: this._instanceId
893
880
  }), {
894
881
  F: __dxlog_file2,
895
- L: 235,
882
+ L: 218,
896
883
  S: this,
897
884
  C: (f, a) => f(...a)
898
885
  });
@@ -902,20 +889,19 @@ var Connection = class {
902
889
  err
903
890
  }, {
904
891
  F: __dxlog_file2,
905
- L: 242,
892
+ L: 225,
906
893
  S: this,
907
894
  C: (f, a) => f(...a)
908
895
  });
909
896
  if (this._state === ConnectionState.CLOSED || this._state === ConnectionState.ABORTED) {
910
897
  (0, import_log2.log)(`abort ignored: already ${this._state}`, this.closeReason, {
911
898
  F: __dxlog_file2,
912
- L: 244,
899
+ L: 227,
913
900
  S: this,
914
901
  C: (f, a) => f(...a)
915
902
  });
916
903
  return;
917
904
  }
918
- await this.connectedTimeoutContext.dispose();
919
905
  this._changeState(ConnectionState.ABORTING);
920
906
  if (!this.closeReason) {
921
907
  this.closeReason = err?.message;
@@ -926,7 +912,7 @@ var Connection = class {
926
912
  proto: this._protocol
927
913
  }, {
928
914
  F: __dxlog_file2,
929
- L: 258,
915
+ L: 240,
930
916
  S: this,
931
917
  C: (f, a) => f(...a)
932
918
  });
@@ -934,7 +920,7 @@ var Connection = class {
934
920
  } catch (err2) {
935
921
  import_log2.log.catch(err2, void 0, {
936
922
  F: __dxlog_file2,
937
- L: 261,
923
+ L: 243,
938
924
  S: this,
939
925
  C: (f, a) => f(...a)
940
926
  });
@@ -944,7 +930,7 @@ var Connection = class {
944
930
  } catch (err2) {
945
931
  import_log2.log.catch(err2, void 0, {
946
932
  F: __dxlog_file2,
947
- L: 268,
933
+ L: 250,
948
934
  S: this,
949
935
  C: (f, a) => f(...a)
950
936
  });
@@ -954,7 +940,7 @@ var Connection = class {
954
940
  } catch (err2) {
955
941
  import_log2.log.catch(err2, void 0, {
956
942
  F: __dxlog_file2,
957
- L: 274,
943
+ L: 256,
958
944
  S: this,
959
945
  C: (f, a) => f(...a)
960
946
  });
@@ -964,21 +950,18 @@ var Connection = class {
964
950
  async close(err) {
965
951
  if (!this.closeReason) {
966
952
  this.closeReason = err?.message;
967
- } else {
968
- this.closeReason += `; ${err?.message}`;
969
953
  }
970
954
  if (this._state === ConnectionState.CLOSED || this._state === ConnectionState.ABORTING || this._state === ConnectionState.ABORTED) {
971
955
  return;
972
956
  }
973
957
  const lastState = this._state;
974
958
  this._changeState(ConnectionState.CLOSING);
975
- await this.connectedTimeoutContext.dispose();
976
959
  await this._ctx.dispose();
977
960
  (0, import_log2.log)("closing...", {
978
961
  peerId: this.ownId
979
962
  }, {
980
963
  F: __dxlog_file2,
981
- L: 299,
964
+ L: 278,
982
965
  S: this,
983
966
  C: (f, a) => f(...a)
984
967
  });
@@ -988,7 +971,7 @@ var Connection = class {
988
971
  } catch (err2) {
989
972
  import_log2.log.catch(err2, void 0, {
990
973
  F: __dxlog_file2,
991
- L: 306,
974
+ L: 285,
992
975
  S: this,
993
976
  C: (f, a) => f(...a)
994
977
  });
@@ -998,7 +981,7 @@ var Connection = class {
998
981
  } catch (err2) {
999
982
  import_log2.log.catch(err2, void 0, {
1000
983
  F: __dxlog_file2,
1001
- L: 313,
984
+ L: 292,
1002
985
  S: this,
1003
986
  C: (f, a) => f(...a)
1004
987
  });
@@ -1008,7 +991,7 @@ var Connection = class {
1008
991
  peerId: this.ownId
1009
992
  }, {
1010
993
  F: __dxlog_file2,
1011
- L: 317,
994
+ L: 296,
1012
995
  S: this,
1013
996
  C: (f, a) => f(...a)
1014
997
  });
@@ -1044,14 +1027,14 @@ var Connection = class {
1044
1027
  }
1045
1028
  });
1046
1029
  } catch (err) {
1047
- if (err instanceof import_protocols.CancelledError || err instanceof Error && err.message?.includes("CANCELLED")) {
1030
+ if (err instanceof import_protocols.CancelledError) {
1048
1031
  return;
1049
1032
  }
1050
1033
  import_log2.log.warn("signal failed", {
1051
1034
  err
1052
1035
  }, {
1053
1036
  F: __dxlog_file2,
1054
- L: 355,
1037
+ L: 333,
1055
1038
  S: this,
1056
1039
  C: (f, a) => f(...a)
1057
1040
  });
@@ -1064,7 +1047,7 @@ var Connection = class {
1064
1047
  async signal(msg) {
1065
1048
  (0, import_invariant.invariant)(msg.sessionId, void 0, {
1066
1049
  F: __dxlog_file2,
1067
- L: 364,
1050
+ L: 342,
1068
1051
  S: this,
1069
1052
  A: [
1070
1053
  "msg.sessionId",
@@ -1074,7 +1057,7 @@ var Connection = class {
1074
1057
  if (!msg.sessionId.equals(this.sessionId)) {
1075
1058
  (0, import_log2.log)("dropping signal for incorrect session id", void 0, {
1076
1059
  F: __dxlog_file2,
1077
- L: 366,
1060
+ L: 344,
1078
1061
  S: this,
1079
1062
  C: (f, a) => f(...a)
1080
1063
  });
@@ -1082,7 +1065,7 @@ var Connection = class {
1082
1065
  }
1083
1066
  (0, import_invariant.invariant)(msg.data.signal || msg.data.signalBatch, void 0, {
1084
1067
  F: __dxlog_file2,
1085
- L: 369,
1068
+ L: 347,
1086
1069
  S: this,
1087
1070
  A: [
1088
1071
  "msg.data.signal || msg.data.signalBatch",
@@ -1091,7 +1074,7 @@ var Connection = class {
1091
1074
  });
1092
1075
  (0, import_invariant.invariant)(msg.author?.equals(this.remoteId), void 0, {
1093
1076
  F: __dxlog_file2,
1094
- L: 370,
1077
+ L: 348,
1095
1078
  S: this,
1096
1079
  A: [
1097
1080
  "msg.author?.equals(this.remoteId)",
@@ -1100,7 +1083,7 @@ var Connection = class {
1100
1083
  });
1101
1084
  (0, import_invariant.invariant)(msg.recipient?.equals(this.ownId), void 0, {
1102
1085
  F: __dxlog_file2,
1103
- L: 371,
1086
+ L: 349,
1104
1087
  S: this,
1105
1088
  A: [
1106
1089
  "msg.recipient?.equals(this.ownId)",
@@ -1124,7 +1107,7 @@ var Connection = class {
1124
1107
  msg: msg.data
1125
1108
  }, {
1126
1109
  F: __dxlog_file2,
1127
- L: 380,
1110
+ L: 358,
1128
1111
  S: this,
1129
1112
  C: (f, a) => f(...a)
1130
1113
  });
@@ -1132,7 +1115,7 @@ var Connection = class {
1132
1115
  } else {
1133
1116
  (0, import_invariant.invariant)(this._transport, "Connection not ready to accept signals.", {
1134
1117
  F: __dxlog_file2,
1135
- L: 383,
1118
+ L: 361,
1136
1119
  S: this,
1137
1120
  A: [
1138
1121
  "this._transport",
@@ -1145,7 +1128,7 @@ var Connection = class {
1145
1128
  msg: msg.data
1146
1129
  }, {
1147
1130
  F: __dxlog_file2,
1148
- L: 384,
1131
+ L: 362,
1149
1132
  S: this,
1150
1133
  C: (f, a) => f(...a)
1151
1134
  });
@@ -1163,13 +1146,13 @@ var Connection = class {
1163
1146
  peerId: this.ownId
1164
1147
  }, {
1165
1148
  F: __dxlog_file2,
1166
- L: 395,
1149
+ L: 373,
1167
1150
  S: this,
1168
1151
  C: (f, a) => f(...a)
1169
1152
  });
1170
1153
  (0, import_invariant.invariant)(state !== this._state, "Already in this state.", {
1171
1154
  F: __dxlog_file2,
1172
- L: 396,
1155
+ L: 374,
1173
1156
  S: this,
1174
1157
  A: [
1175
1158
  "state !== this._state",
@@ -1246,12 +1229,11 @@ var Peer = class {
1246
1229
  const remoteId = message.author;
1247
1230
  if (this.connection && ![
1248
1231
  ConnectionState.CREATED,
1249
- ConnectionState.INITIAL,
1250
- ConnectionState.CONNECTING
1232
+ ConnectionState.INITIAL
1251
1233
  ].includes(this.connection.state)) {
1252
1234
  import_log3.log.info(`received offer when connection already in ${this.connection.state} state`, void 0, {
1253
1235
  F: __dxlog_file3,
1254
- L: 115,
1236
+ L: 112,
1255
1237
  S: this,
1256
1238
  C: (f, a) => f(...a)
1257
1239
  });
@@ -1268,7 +1250,7 @@ var Peer = class {
1268
1250
  sessionId: this.connection?.sessionId
1269
1251
  }, {
1270
1252
  F: __dxlog_file3,
1271
- L: 124,
1253
+ L: 121,
1272
1254
  S: this,
1273
1255
  C: (f, a) => f(...a)
1274
1256
  });
@@ -1285,7 +1267,7 @@ var Peer = class {
1285
1267
  if (!this.connection) {
1286
1268
  (0, import_invariant2.invariant)(message.sessionId, void 0, {
1287
1269
  F: __dxlog_file3,
1288
- L: 144,
1270
+ L: 141,
1289
1271
  S: this,
1290
1272
  A: [
1291
1273
  "message.sessionId",
@@ -1306,7 +1288,7 @@ var Peer = class {
1306
1288
  err
1307
1289
  }, {
1308
1290
  F: __dxlog_file3,
1309
- L: 154,
1291
+ L: 151,
1310
1292
  S: this,
1311
1293
  C: (f, a) => f(...a)
1312
1294
  });
@@ -1328,7 +1310,7 @@ var Peer = class {
1328
1310
  async initiateConnection() {
1329
1311
  (0, import_invariant2.invariant)(!this.initiating, "Initiation in progress.", {
1330
1312
  F: __dxlog_file3,
1331
- L: 171,
1313
+ L: 168,
1332
1314
  S: this,
1333
1315
  A: [
1334
1316
  "!this.initiating",
@@ -1337,7 +1319,7 @@ var Peer = class {
1337
1319
  });
1338
1320
  (0, import_invariant2.invariant)(!this.connection, "Already connected.", {
1339
1321
  F: __dxlog_file3,
1340
- L: 172,
1322
+ L: 169,
1341
1323
  S: this,
1342
1324
  A: [
1343
1325
  "!this.connection",
@@ -1352,17 +1334,16 @@ var Peer = class {
1352
1334
  sessionId
1353
1335
  }, {
1354
1336
  F: __dxlog_file3,
1355
- L: 174,
1337
+ L: 171,
1356
1338
  S: this,
1357
1339
  C: (f, a) => f(...a)
1358
1340
  });
1359
1341
  const connection = this._createConnection(true, sessionId);
1360
1342
  this.initiating = true;
1361
- let answer;
1362
1343
  try {
1363
1344
  await this._connectionLimiter.connecting(sessionId);
1364
1345
  connection.initiate();
1365
- answer = await this._signalMessaging.offer({
1346
+ const answer = await this._signalMessaging.offer({
1366
1347
  author: this.localPeerId,
1367
1348
  recipient: this.id,
1368
1349
  sessionId,
@@ -1378,87 +1359,46 @@ var Peer = class {
1378
1359
  remoteId: this.id
1379
1360
  }, {
1380
1361
  F: __dxlog_file3,
1381
- L: 191,
1362
+ L: 187,
1382
1363
  S: this,
1383
1364
  C: (f, a) => f(...a)
1384
1365
  });
1385
1366
  if (connection.state !== ConnectionState.INITIAL) {
1386
1367
  (0, import_log3.log)("ignoring response", void 0, {
1387
1368
  F: __dxlog_file3,
1388
- L: 193,
1369
+ L: 189,
1389
1370
  S: this,
1390
1371
  C: (f, a) => f(...a)
1391
1372
  });
1392
1373
  return;
1393
1374
  }
1394
- } catch (err) {
1395
- (0, import_log3.log)("initiation error: send offer", {
1396
- err,
1397
- topic: this.topic,
1398
- peerId: this.localPeerId,
1399
- remoteId: this.id
1400
- }, {
1401
- F: __dxlog_file3,
1402
- L: 197,
1403
- S: this,
1404
- C: (f, a) => f(...a)
1405
- });
1406
- await connection.abort(err);
1407
- throw err;
1408
- } finally {
1409
- this.initiating = false;
1410
- }
1411
- try {
1412
1375
  if (!answer.accept) {
1413
1376
  this._callbacks.onRejected();
1414
1377
  return;
1415
1378
  }
1416
- } catch (err) {
1417
- (0, import_log3.log)("initiation error: accept answer", {
1418
- err,
1419
- topic: this.topic,
1420
- peerId: this.localPeerId,
1421
- remoteId: this.id
1422
- }, {
1423
- F: __dxlog_file3,
1424
- L: 210,
1425
- S: this,
1426
- C: (f, a) => f(...a)
1427
- });
1428
- await connection.abort(err);
1429
- throw err;
1430
- } finally {
1431
- this.initiating = false;
1432
- }
1433
- try {
1434
- (0, import_log3.log)("opening connection as initiator", void 0, {
1435
- F: __dxlog_file3,
1436
- L: 223,
1437
- S: this,
1438
- C: (f, a) => f(...a)
1439
- });
1440
1379
  await connection.openConnection();
1441
1380
  this._callbacks.onAccepted();
1442
1381
  } catch (err) {
1443
- (0, import_log3.log)("initiation error: open connection", {
1382
+ (0, import_log3.log)("initiation error", {
1444
1383
  err,
1445
1384
  topic: this.topic,
1446
1385
  peerId: this.localPeerId,
1447
1386
  remoteId: this.id
1448
1387
  }, {
1449
1388
  F: __dxlog_file3,
1450
- L: 227,
1451
- S: this,
1452
- C: (f, a) => f(...a)
1453
- });
1454
- import_log3.log.warn("closing connection due to unhandled error on openConnection", {
1455
- err
1456
- }, {
1457
- F: __dxlog_file3,
1458
- L: 234,
1389
+ L: 200,
1459
1390
  S: this,
1460
1391
  C: (f, a) => f(...a)
1461
1392
  });
1393
+ if (err instanceof import_protocols2.TimeoutError) {
1394
+ import_log3.log.warn("aborting connection due to signalling failure", void 0, {
1395
+ F: __dxlog_file3,
1396
+ L: 202,
1397
+ S: this,
1398
+ C: (f, a) => f(...a)
1399
+ });
1400
+ await connection.abort(err);
1401
+ }
1462
1402
  await this.closeConnection(err);
1463
1403
  throw err;
1464
1404
  } finally {
@@ -1478,13 +1418,13 @@ var Peer = class {
1478
1418
  sessionId
1479
1419
  }, {
1480
1420
  F: __dxlog_file3,
1481
- L: 248,
1421
+ L: 218,
1482
1422
  S: this,
1483
1423
  C: (f, a) => f(...a)
1484
1424
  });
1485
1425
  (0, import_invariant2.invariant)(!this.connection, "Already connected.", {
1486
1426
  F: __dxlog_file3,
1487
- L: 255,
1427
+ L: 225,
1488
1428
  S: this,
1489
1429
  A: [
1490
1430
  "!this.connection",
@@ -1520,7 +1460,7 @@ var Peer = class {
1520
1460
  initiator
1521
1461
  }, {
1522
1462
  F: __dxlog_file3,
1523
- L: 274,
1463
+ L: 244,
1524
1464
  S: this,
1525
1465
  C: (f, a) => f(...a)
1526
1466
  });
@@ -1533,14 +1473,14 @@ var Peer = class {
1533
1473
  initiator
1534
1474
  }, {
1535
1475
  F: __dxlog_file3,
1536
- L: 283,
1476
+ L: 253,
1537
1477
  S: this,
1538
1478
  C: (f, a) => f(...a)
1539
1479
  });
1540
1480
  this._connectionLimiter.doneConnecting(sessionId);
1541
1481
  (0, import_invariant2.invariant)(this.connection === connection, "Connection mismatch (race condition).", {
1542
1482
  F: __dxlog_file3,
1543
- L: 288,
1483
+ L: 258,
1544
1484
  S: this,
1545
1485
  A: [
1546
1486
  "this.connection === connection",
@@ -1555,7 +1495,7 @@ var Peer = class {
1555
1495
  initiator
1556
1496
  }, {
1557
1497
  F: __dxlog_file3,
1558
- L: 290,
1498
+ L: 260,
1559
1499
  S: this,
1560
1500
  C: (f, a) => f(...a)
1561
1501
  });
@@ -1582,7 +1522,7 @@ var Peer = class {
1582
1522
  void this._connectionCtx?.dispose();
1583
1523
  this._connectionCtx = this._ctx.derive();
1584
1524
  connection.errors.handle((err) => {
1585
- import_log3.log.warn("connection error, closing", {
1525
+ import_log3.log.warn("connection error", {
1586
1526
  topic: this.topic,
1587
1527
  peerId: this.localPeerId,
1588
1528
  remoteId: this.id,
@@ -1590,7 +1530,7 @@ var Peer = class {
1590
1530
  err
1591
1531
  }, {
1592
1532
  F: __dxlog_file3,
1593
- L: 330,
1533
+ L: 300,
1594
1534
  S: this,
1595
1535
  C: (f, a) => f(...a)
1596
1536
  });
@@ -1603,7 +1543,7 @@ var Peer = class {
1603
1543
  err
1604
1544
  }, {
1605
1545
  F: __dxlog_file3,
1606
- L: 337,
1546
+ L: 301,
1607
1547
  S: this,
1608
1548
  C: (f, a) => f(...a)
1609
1549
  });
@@ -1622,7 +1562,7 @@ var Peer = class {
1622
1562
  sessionId: connection.sessionId
1623
1563
  }, {
1624
1564
  F: __dxlog_file3,
1625
- L: 362,
1565
+ L: 326,
1626
1566
  S: this,
1627
1567
  C: (f, a) => f(...a)
1628
1568
  });
@@ -1632,7 +1572,7 @@ var Peer = class {
1632
1572
  sessionId: connection.sessionId
1633
1573
  }, {
1634
1574
  F: __dxlog_file3,
1635
- L: 368,
1575
+ L: 332,
1636
1576
  S: this,
1637
1577
  C: (f, a) => f(...a)
1638
1578
  });
@@ -1643,7 +1583,7 @@ var Peer = class {
1643
1583
  message
1644
1584
  }, {
1645
1585
  F: __dxlog_file3,
1646
- L: 373,
1586
+ L: 337,
1647
1587
  S: this,
1648
1588
  C: (f, a) => f(...a)
1649
1589
  });
@@ -1651,18 +1591,18 @@ var Peer = class {
1651
1591
  }
1652
1592
  await this.connection.signal(message);
1653
1593
  }
1654
- async destroy(reason) {
1594
+ async destroy() {
1655
1595
  await this._ctx.dispose();
1656
1596
  (0, import_log3.log)("Destroying peer", {
1657
1597
  peerId: this.id,
1658
1598
  topic: this.topic
1659
1599
  }, {
1660
1600
  F: __dxlog_file3,
1661
- L: 383,
1601
+ L: 347,
1662
1602
  S: this,
1663
1603
  C: (f, a) => f(...a)
1664
1604
  });
1665
- await this?.connection?.close(reason);
1605
+ await this?.connection?.close();
1666
1606
  }
1667
1607
  };
1668
1608
  _ts_decorate2([
@@ -2035,7 +1975,7 @@ var Swarm = class {
2035
1975
  this._listeningHandle = void 0;
2036
1976
  await this._ctx.dispose();
2037
1977
  await this._topology.destroy();
2038
- await Promise.all(Array.from(this._peers.keys()).map((key) => this._destroyPeer(key, "swarm destroyed")));
1978
+ await Promise.all(Array.from(this._peers.keys()).map((key) => this._destroyPeer(key)));
2039
1979
  (0, import_log5.log)("destroyed", void 0, {
2040
1980
  F: __dxlog_file5,
2041
1981
  L: 148,
@@ -2107,22 +2047,13 @@ var Swarm = class {
2107
2047
  if (peer) {
2108
2048
  peer.advertizing = false;
2109
2049
  if (peer.connection?.state !== ConnectionState.CONNECTED) {
2110
- void this._destroyPeer(peer.id, "peer left").catch((err) => import_log5.log.catch(err, void 0, {
2050
+ void this._destroyPeer(peer.id).catch((err) => import_log5.log.catch(err, void 0, {
2111
2051
  F: __dxlog_file5,
2112
2052
  L: 189,
2113
2053
  S: this,
2114
2054
  C: (f, a) => f(...a)
2115
2055
  }));
2116
2056
  }
2117
- } else {
2118
- (0, import_log5.log)("received peerLeft but no peer found", {
2119
- peer: swarmEvent.peerLeft.peer
2120
- }, {
2121
- F: __dxlog_file5,
2122
- L: 192,
2123
- S: this,
2124
- C: (f, a) => f(...a)
2125
- });
2126
2057
  }
2127
2058
  }
2128
2059
  this._topology.update();
@@ -2132,14 +2063,14 @@ var Swarm = class {
2132
2063
  message
2133
2064
  }, {
2134
2065
  F: __dxlog_file5,
2135
- L: 201,
2066
+ L: 199,
2136
2067
  S: this,
2137
2068
  C: (f, a) => f(...a)
2138
2069
  });
2139
2070
  if (this._ctx.disposed) {
2140
2071
  (0, import_log5.log)("ignored for disposed swarm", void 0, {
2141
2072
  F: __dxlog_file5,
2142
- L: 203,
2073
+ L: 201,
2143
2074
  S: this,
2144
2075
  C: (f, a) => f(...a)
2145
2076
  });
@@ -2149,7 +2080,7 @@ var Swarm = class {
2149
2080
  }
2150
2081
  (0, import_invariant4.invariant)(message.author, void 0, {
2151
2082
  F: __dxlog_file5,
2152
- L: 208,
2083
+ L: 206,
2153
2084
  S: this,
2154
2085
  A: [
2155
2086
  "message.author",
@@ -2161,7 +2092,7 @@ var Swarm = class {
2161
2092
  message
2162
2093
  }, {
2163
2094
  F: __dxlog_file5,
2164
- L: 210,
2095
+ L: 208,
2165
2096
  S: this,
2166
2097
  C: (f, a) => f(...a)
2167
2098
  });
@@ -2174,7 +2105,7 @@ var Swarm = class {
2174
2105
  message
2175
2106
  }, {
2176
2107
  F: __dxlog_file5,
2177
- L: 214,
2108
+ L: 212,
2178
2109
  S: this,
2179
2110
  C: (f, a) => f(...a)
2180
2111
  });
@@ -2192,14 +2123,14 @@ var Swarm = class {
2192
2123
  message
2193
2124
  }, {
2194
2125
  F: __dxlog_file5,
2195
- L: 225,
2126
+ L: 223,
2196
2127
  S: this,
2197
2128
  C: (f, a) => f(...a)
2198
2129
  });
2199
2130
  if (this._ctx.disposed) {
2200
2131
  import_log5.log.info("ignored for offline swarm", void 0, {
2201
2132
  F: __dxlog_file5,
2202
- L: 227,
2133
+ L: 225,
2203
2134
  S: this,
2204
2135
  C: (f, a) => f(...a)
2205
2136
  });
@@ -2207,7 +2138,7 @@ var Swarm = class {
2207
2138
  }
2208
2139
  (0, import_invariant4.invariant)(message.recipient?.equals(this._ownPeerId), `Invalid signal peer id expected=${this.ownPeerId}, actual=${message.recipient}`, {
2209
2140
  F: __dxlog_file5,
2210
- L: 230,
2141
+ L: 228,
2211
2142
  S: this,
2212
2143
  A: [
2213
2144
  "message.recipient?.equals(this._ownPeerId)",
@@ -2216,7 +2147,7 @@ var Swarm = class {
2216
2147
  });
2217
2148
  (0, import_invariant4.invariant)(message.topic?.equals(this._topic), void 0, {
2218
2149
  F: __dxlog_file5,
2219
- L: 234,
2150
+ L: 232,
2220
2151
  S: this,
2221
2152
  A: [
2222
2153
  "message.topic?.equals(this._topic)",
@@ -2225,7 +2156,7 @@ var Swarm = class {
2225
2156
  });
2226
2157
  (0, import_invariant4.invariant)(message.author, void 0, {
2227
2158
  F: __dxlog_file5,
2228
- L: 235,
2159
+ L: 233,
2229
2160
  S: this,
2230
2161
  A: [
2231
2162
  "message.author",
@@ -2240,7 +2171,7 @@ var Swarm = class {
2240
2171
  await this._ctx.dispose();
2241
2172
  await Promise.all([
2242
2173
  ...this._peers.keys()
2243
- ].map((peerId) => this._destroyPeer(peerId, "goOffline")));
2174
+ ].map((peerId) => this._destroyPeer(peerId)));
2244
2175
  }
2245
2176
  // For debug purposes
2246
2177
  async goOnline() {
@@ -2258,22 +2189,14 @@ var Swarm = class {
2258
2189
  },
2259
2190
  onDisconnected: async () => {
2260
2191
  if (!peer.advertizing) {
2261
- await this._destroyPeer(peer.id, "peer disconnected");
2192
+ await this._destroyPeer(peer.id);
2262
2193
  }
2263
2194
  this.disconnected.emit(peerId);
2264
2195
  this._topology.update();
2265
2196
  },
2266
2197
  onRejected: () => {
2267
2198
  if (this._peers.has(peerId)) {
2268
- (0, import_log5.log)("peer rejected connection", {
2269
- peerId
2270
- }, {
2271
- F: __dxlog_file5,
2272
- L: 284,
2273
- S: this,
2274
- C: (f, a) => f(...a)
2275
- });
2276
- void this._destroyPeer(peerId, "peer rejected connection");
2199
+ void this._destroyPeer(peerId);
2277
2200
  }
2278
2201
  },
2279
2202
  onAccepted: () => {
@@ -2290,17 +2213,17 @@ var Swarm = class {
2290
2213
  }
2291
2214
  return peer;
2292
2215
  }
2293
- async _destroyPeer(peerId, reason) {
2216
+ async _destroyPeer(peerId) {
2294
2217
  (0, import_invariant4.invariant)(this._peers.has(peerId), void 0, {
2295
2218
  F: __dxlog_file5,
2296
- L: 306,
2219
+ L: 303,
2297
2220
  S: this,
2298
2221
  A: [
2299
2222
  "this._peers.has(peerId)",
2300
2223
  ""
2301
2224
  ]
2302
2225
  });
2303
- await this._peers.get(peerId).destroy(new Error(reason));
2226
+ await this._peers.get(peerId).destroy();
2304
2227
  this._peers.delete(peerId);
2305
2228
  }
2306
2229
  _getSwarmController() {
@@ -2320,7 +2243,7 @@ var Swarm = class {
2320
2243
  } catch (err) {
2321
2244
  (0, import_log5.log)("initiation error", err, {
2322
2245
  F: __dxlog_file5,
2323
- L: 332,
2246
+ L: 329,
2324
2247
  S: this,
2325
2248
  C: (f, a) => f(...a)
2326
2249
  });
@@ -2348,7 +2271,7 @@ var Swarm = class {
2348
2271
  remoteId
2349
2272
  }, {
2350
2273
  F: __dxlog_file5,
2351
- L: 359,
2274
+ L: 356,
2352
2275
  S: this,
2353
2276
  C: (f, a) => f(...a)
2354
2277
  });
@@ -2365,7 +2288,7 @@ var Swarm = class {
2365
2288
  remoteId
2366
2289
  }, {
2367
2290
  F: __dxlog_file5,
2368
- L: 373,
2291
+ L: 370,
2369
2292
  S: this,
2370
2293
  C: (f, a) => f(...a)
2371
2294
  });
@@ -2375,7 +2298,7 @@ var Swarm = class {
2375
2298
  remoteId
2376
2299
  }, {
2377
2300
  F: __dxlog_file5,
2378
- L: 376,
2301
+ L: 373,
2379
2302
  S: this,
2380
2303
  C: (f, a) => f(...a)
2381
2304
  });