@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.
@@ -563,7 +563,6 @@ function _ts_decorate(decorators, target, key, desc) {
563
563
  }
564
564
  var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/connection.ts";
565
565
  var STARTING_SIGNALLING_DELAY = 10;
566
- var TRANSPORT_CONNECTION_TIMEOUT = 1e4;
567
566
  var MAX_SIGNALLING_DELAY = 300;
568
567
  var ConnectionState;
569
568
  (function(ConnectionState5) {
@@ -619,7 +618,6 @@ var Connection = class {
619
618
  this._transportFactory = _transportFactory;
620
619
  this._callbacks = _callbacks;
621
620
  this._ctx = new import_context.Context();
622
- this.connectedTimeoutContext = new import_context.Context();
623
621
  this._state = ConnectionState.CREATED;
624
622
  this._incomingSignalBuffer = [];
625
623
  this._outgoingSignalBuffer = [];
@@ -638,7 +636,7 @@ var Connection = class {
638
636
  initiator: this.initiator
639
637
  }, {
640
638
  F: __dxlog_file,
641
- L: 129,
639
+ L: 123,
642
640
  S: this,
643
641
  C: (f, a) => f(...a)
644
642
  });
@@ -658,7 +656,7 @@ var Connection = class {
658
656
  async openConnection() {
659
657
  (0, import_invariant.invariant)(this._state === ConnectionState.INITIAL, "Invalid state.", {
660
658
  F: __dxlog_file,
661
- L: 154,
659
+ L: 148,
662
660
  S: this,
663
661
  A: [
664
662
  "this._state === ConnectionState.INITIAL",
@@ -669,7 +667,7 @@ var Connection = class {
669
667
  id: this._instanceId
670
668
  }), {
671
669
  F: __dxlog_file,
672
- L: 155,
670
+ L: 149,
673
671
  S: this,
674
672
  C: (f, a) => f(...a)
675
673
  });
@@ -681,7 +679,7 @@ var Connection = class {
681
679
  initiator: this.initiator
682
680
  }, {
683
681
  F: __dxlog_file,
684
- L: 156,
682
+ L: 150,
685
683
  S: this,
686
684
  C: (f, a) => f(...a)
687
685
  });
@@ -692,24 +690,15 @@ var Connection = class {
692
690
  this._protocol.stream.on("close", () => {
693
691
  (0, import_log.log)("protocol stream closed", void 0, {
694
692
  F: __dxlog_file,
695
- L: 173,
693
+ L: 167,
696
694
  S: this,
697
695
  C: (f, a) => f(...a)
698
696
  });
699
697
  this.close(new import_protocols.ProtocolError("protocol stream closed")).catch((err) => this.errors.raise(err));
700
698
  });
701
- (0, import_async.scheduleTask)(this.connectedTimeoutContext, async () => {
702
- import_log.log.warn("timeout waiting for transport to connect, aborting", void 0, {
703
- F: __dxlog_file,
704
- L: 180,
705
- S: this,
706
- C: (f, a) => f(...a)
707
- });
708
- await this.abort().catch((err) => this.errors.raise(err));
709
- }, TRANSPORT_CONNECTION_TIMEOUT);
710
699
  (0, import_invariant.invariant)(!this._transport, void 0, {
711
700
  F: __dxlog_file,
712
- L: 186,
701
+ L: 171,
713
702
  S: this,
714
703
  A: [
715
704
  "!this._transport",
@@ -721,27 +710,26 @@ var Connection = class {
721
710
  stream: this._protocol.stream,
722
711
  sendSignal: async (signal) => this._sendSignal(signal)
723
712
  });
724
- this._transport.connected.once(async () => {
713
+ this._transport.connected.once(() => {
725
714
  this._changeState(ConnectionState.CONNECTED);
726
- await this.connectedTimeoutContext.dispose();
727
715
  this._callbacks?.onConnected?.();
728
716
  });
729
717
  this._transport.closed.once(() => {
730
718
  this._transport = void 0;
731
719
  (0, import_log.log)("abort triggered by transport close", void 0, {
732
720
  F: __dxlog_file,
733
- L: 201,
721
+ L: 185,
734
722
  S: this,
735
723
  C: (f, a) => f(...a)
736
724
  });
737
725
  this.abort().catch((err) => this.errors.raise(err));
738
726
  });
739
- this._transport.errors.handle(async (err) => {
727
+ this._transport.errors.handle((err) => {
740
728
  (0, import_log.log)("transport error:", {
741
729
  err
742
730
  }, {
743
731
  F: __dxlog_file,
744
- L: 206,
732
+ L: 190,
745
733
  S: this,
746
734
  C: (f, a) => f(...a)
747
735
  });
@@ -751,7 +739,7 @@ var Connection = class {
751
739
  if (err instanceof import_protocols.ConnectionResetError) {
752
740
  import_log.log.warn("aborting due to transport ConnectionResetError", void 0, {
753
741
  F: __dxlog_file,
754
- L: 213,
742
+ L: 197,
755
743
  S: this,
756
744
  C: (f, a) => f(...a)
757
745
  });
@@ -759,7 +747,7 @@ var Connection = class {
759
747
  } else if (err instanceof import_protocols.ConnectivityError) {
760
748
  import_log.log.warn("aborting due to transport ConnectivityError", void 0, {
761
749
  F: __dxlog_file,
762
- L: 216,
750
+ L: 200,
763
751
  S: this,
764
752
  C: (f, a) => f(...a)
765
753
  });
@@ -769,13 +757,12 @@ var Connection = class {
769
757
  err
770
758
  }, {
771
759
  F: __dxlog_file,
772
- L: 219,
760
+ L: 203,
773
761
  S: this,
774
762
  C: (f, a) => f(...a)
775
763
  });
776
764
  }
777
765
  if (this._state !== ConnectionState.CLOSED && this._state !== ConnectionState.CLOSING) {
778
- await this.connectedTimeoutContext.dispose();
779
766
  this.errors.raise(err);
780
767
  }
781
768
  });
@@ -787,7 +774,7 @@ var Connection = class {
787
774
  id: this._instanceId
788
775
  }), {
789
776
  F: __dxlog_file,
790
- L: 235,
777
+ L: 218,
791
778
  S: this,
792
779
  C: (f, a) => f(...a)
793
780
  });
@@ -797,20 +784,19 @@ var Connection = class {
797
784
  err
798
785
  }, {
799
786
  F: __dxlog_file,
800
- L: 242,
787
+ L: 225,
801
788
  S: this,
802
789
  C: (f, a) => f(...a)
803
790
  });
804
791
  if (this._state === ConnectionState.CLOSED || this._state === ConnectionState.ABORTED) {
805
792
  (0, import_log.log)(`abort ignored: already ${this._state}`, this.closeReason, {
806
793
  F: __dxlog_file,
807
- L: 244,
794
+ L: 227,
808
795
  S: this,
809
796
  C: (f, a) => f(...a)
810
797
  });
811
798
  return;
812
799
  }
813
- await this.connectedTimeoutContext.dispose();
814
800
  this._changeState(ConnectionState.ABORTING);
815
801
  if (!this.closeReason) {
816
802
  this.closeReason = err?.message;
@@ -821,7 +807,7 @@ var Connection = class {
821
807
  proto: this._protocol
822
808
  }, {
823
809
  F: __dxlog_file,
824
- L: 258,
810
+ L: 240,
825
811
  S: this,
826
812
  C: (f, a) => f(...a)
827
813
  });
@@ -829,7 +815,7 @@ var Connection = class {
829
815
  } catch (err2) {
830
816
  import_log.log.catch(err2, void 0, {
831
817
  F: __dxlog_file,
832
- L: 261,
818
+ L: 243,
833
819
  S: this,
834
820
  C: (f, a) => f(...a)
835
821
  });
@@ -839,7 +825,7 @@ var Connection = class {
839
825
  } catch (err2) {
840
826
  import_log.log.catch(err2, void 0, {
841
827
  F: __dxlog_file,
842
- L: 268,
828
+ L: 250,
843
829
  S: this,
844
830
  C: (f, a) => f(...a)
845
831
  });
@@ -849,7 +835,7 @@ var Connection = class {
849
835
  } catch (err2) {
850
836
  import_log.log.catch(err2, void 0, {
851
837
  F: __dxlog_file,
852
- L: 274,
838
+ L: 256,
853
839
  S: this,
854
840
  C: (f, a) => f(...a)
855
841
  });
@@ -859,21 +845,18 @@ var Connection = class {
859
845
  async close(err) {
860
846
  if (!this.closeReason) {
861
847
  this.closeReason = err?.message;
862
- } else {
863
- this.closeReason += `; ${err?.message}`;
864
848
  }
865
849
  if (this._state === ConnectionState.CLOSED || this._state === ConnectionState.ABORTING || this._state === ConnectionState.ABORTED) {
866
850
  return;
867
851
  }
868
852
  const lastState = this._state;
869
853
  this._changeState(ConnectionState.CLOSING);
870
- await this.connectedTimeoutContext.dispose();
871
854
  await this._ctx.dispose();
872
855
  (0, import_log.log)("closing...", {
873
856
  peerId: this.ownId
874
857
  }, {
875
858
  F: __dxlog_file,
876
- L: 299,
859
+ L: 278,
877
860
  S: this,
878
861
  C: (f, a) => f(...a)
879
862
  });
@@ -883,7 +866,7 @@ var Connection = class {
883
866
  } catch (err2) {
884
867
  import_log.log.catch(err2, void 0, {
885
868
  F: __dxlog_file,
886
- L: 306,
869
+ L: 285,
887
870
  S: this,
888
871
  C: (f, a) => f(...a)
889
872
  });
@@ -893,7 +876,7 @@ var Connection = class {
893
876
  } catch (err2) {
894
877
  import_log.log.catch(err2, void 0, {
895
878
  F: __dxlog_file,
896
- L: 313,
879
+ L: 292,
897
880
  S: this,
898
881
  C: (f, a) => f(...a)
899
882
  });
@@ -903,7 +886,7 @@ var Connection = class {
903
886
  peerId: this.ownId
904
887
  }, {
905
888
  F: __dxlog_file,
906
- L: 317,
889
+ L: 296,
907
890
  S: this,
908
891
  C: (f, a) => f(...a)
909
892
  });
@@ -939,14 +922,14 @@ var Connection = class {
939
922
  }
940
923
  });
941
924
  } catch (err) {
942
- if (err instanceof import_protocols.CancelledError || err instanceof Error && err.message?.includes("CANCELLED")) {
925
+ if (err instanceof import_protocols.CancelledError) {
943
926
  return;
944
927
  }
945
928
  import_log.log.warn("signal failed", {
946
929
  err
947
930
  }, {
948
931
  F: __dxlog_file,
949
- L: 355,
932
+ L: 333,
950
933
  S: this,
951
934
  C: (f, a) => f(...a)
952
935
  });
@@ -959,7 +942,7 @@ var Connection = class {
959
942
  async signal(msg) {
960
943
  (0, import_invariant.invariant)(msg.sessionId, void 0, {
961
944
  F: __dxlog_file,
962
- L: 364,
945
+ L: 342,
963
946
  S: this,
964
947
  A: [
965
948
  "msg.sessionId",
@@ -969,7 +952,7 @@ var Connection = class {
969
952
  if (!msg.sessionId.equals(this.sessionId)) {
970
953
  (0, import_log.log)("dropping signal for incorrect session id", void 0, {
971
954
  F: __dxlog_file,
972
- L: 366,
955
+ L: 344,
973
956
  S: this,
974
957
  C: (f, a) => f(...a)
975
958
  });
@@ -977,7 +960,7 @@ var Connection = class {
977
960
  }
978
961
  (0, import_invariant.invariant)(msg.data.signal || msg.data.signalBatch, void 0, {
979
962
  F: __dxlog_file,
980
- L: 369,
963
+ L: 347,
981
964
  S: this,
982
965
  A: [
983
966
  "msg.data.signal || msg.data.signalBatch",
@@ -986,7 +969,7 @@ var Connection = class {
986
969
  });
987
970
  (0, import_invariant.invariant)(msg.author?.equals(this.remoteId), void 0, {
988
971
  F: __dxlog_file,
989
- L: 370,
972
+ L: 348,
990
973
  S: this,
991
974
  A: [
992
975
  "msg.author?.equals(this.remoteId)",
@@ -995,7 +978,7 @@ var Connection = class {
995
978
  });
996
979
  (0, import_invariant.invariant)(msg.recipient?.equals(this.ownId), void 0, {
997
980
  F: __dxlog_file,
998
- L: 371,
981
+ L: 349,
999
982
  S: this,
1000
983
  A: [
1001
984
  "msg.recipient?.equals(this.ownId)",
@@ -1019,7 +1002,7 @@ var Connection = class {
1019
1002
  msg: msg.data
1020
1003
  }, {
1021
1004
  F: __dxlog_file,
1022
- L: 380,
1005
+ L: 358,
1023
1006
  S: this,
1024
1007
  C: (f, a) => f(...a)
1025
1008
  });
@@ -1027,7 +1010,7 @@ var Connection = class {
1027
1010
  } else {
1028
1011
  (0, import_invariant.invariant)(this._transport, "Connection not ready to accept signals.", {
1029
1012
  F: __dxlog_file,
1030
- L: 383,
1013
+ L: 361,
1031
1014
  S: this,
1032
1015
  A: [
1033
1016
  "this._transport",
@@ -1040,7 +1023,7 @@ var Connection = class {
1040
1023
  msg: msg.data
1041
1024
  }, {
1042
1025
  F: __dxlog_file,
1043
- L: 384,
1026
+ L: 362,
1044
1027
  S: this,
1045
1028
  C: (f, a) => f(...a)
1046
1029
  });
@@ -1058,13 +1041,13 @@ var Connection = class {
1058
1041
  peerId: this.ownId
1059
1042
  }, {
1060
1043
  F: __dxlog_file,
1061
- L: 395,
1044
+ L: 373,
1062
1045
  S: this,
1063
1046
  C: (f, a) => f(...a)
1064
1047
  });
1065
1048
  (0, import_invariant.invariant)(state !== this._state, "Already in this state.", {
1066
1049
  F: __dxlog_file,
1067
- L: 396,
1050
+ L: 374,
1068
1051
  S: this,
1069
1052
  A: [
1070
1053
  "state !== this._state",
@@ -1141,12 +1124,11 @@ var Peer = class {
1141
1124
  const remoteId = message.author;
1142
1125
  if (this.connection && ![
1143
1126
  ConnectionState.CREATED,
1144
- ConnectionState.INITIAL,
1145
- ConnectionState.CONNECTING
1127
+ ConnectionState.INITIAL
1146
1128
  ].includes(this.connection.state)) {
1147
1129
  import_log2.log.info(`received offer when connection already in ${this.connection.state} state`, void 0, {
1148
1130
  F: __dxlog_file2,
1149
- L: 115,
1131
+ L: 112,
1150
1132
  S: this,
1151
1133
  C: (f, a) => f(...a)
1152
1134
  });
@@ -1163,7 +1145,7 @@ var Peer = class {
1163
1145
  sessionId: this.connection?.sessionId
1164
1146
  }, {
1165
1147
  F: __dxlog_file2,
1166
- L: 124,
1148
+ L: 121,
1167
1149
  S: this,
1168
1150
  C: (f, a) => f(...a)
1169
1151
  });
@@ -1180,7 +1162,7 @@ var Peer = class {
1180
1162
  if (!this.connection) {
1181
1163
  (0, import_invariant2.invariant)(message.sessionId, void 0, {
1182
1164
  F: __dxlog_file2,
1183
- L: 144,
1165
+ L: 141,
1184
1166
  S: this,
1185
1167
  A: [
1186
1168
  "message.sessionId",
@@ -1201,7 +1183,7 @@ var Peer = class {
1201
1183
  err
1202
1184
  }, {
1203
1185
  F: __dxlog_file2,
1204
- L: 154,
1186
+ L: 151,
1205
1187
  S: this,
1206
1188
  C: (f, a) => f(...a)
1207
1189
  });
@@ -1223,7 +1205,7 @@ var Peer = class {
1223
1205
  async initiateConnection() {
1224
1206
  (0, import_invariant2.invariant)(!this.initiating, "Initiation in progress.", {
1225
1207
  F: __dxlog_file2,
1226
- L: 171,
1208
+ L: 168,
1227
1209
  S: this,
1228
1210
  A: [
1229
1211
  "!this.initiating",
@@ -1232,7 +1214,7 @@ var Peer = class {
1232
1214
  });
1233
1215
  (0, import_invariant2.invariant)(!this.connection, "Already connected.", {
1234
1216
  F: __dxlog_file2,
1235
- L: 172,
1217
+ L: 169,
1236
1218
  S: this,
1237
1219
  A: [
1238
1220
  "!this.connection",
@@ -1247,17 +1229,16 @@ var Peer = class {
1247
1229
  sessionId
1248
1230
  }, {
1249
1231
  F: __dxlog_file2,
1250
- L: 174,
1232
+ L: 171,
1251
1233
  S: this,
1252
1234
  C: (f, a) => f(...a)
1253
1235
  });
1254
1236
  const connection = this._createConnection(true, sessionId);
1255
1237
  this.initiating = true;
1256
- let answer;
1257
1238
  try {
1258
1239
  await this._connectionLimiter.connecting(sessionId);
1259
1240
  connection.initiate();
1260
- answer = await this._signalMessaging.offer({
1241
+ const answer = await this._signalMessaging.offer({
1261
1242
  author: this.localPeerId,
1262
1243
  recipient: this.id,
1263
1244
  sessionId,
@@ -1273,87 +1254,46 @@ var Peer = class {
1273
1254
  remoteId: this.id
1274
1255
  }, {
1275
1256
  F: __dxlog_file2,
1276
- L: 191,
1257
+ L: 187,
1277
1258
  S: this,
1278
1259
  C: (f, a) => f(...a)
1279
1260
  });
1280
1261
  if (connection.state !== ConnectionState.INITIAL) {
1281
1262
  (0, import_log2.log)("ignoring response", void 0, {
1282
1263
  F: __dxlog_file2,
1283
- L: 193,
1264
+ L: 189,
1284
1265
  S: this,
1285
1266
  C: (f, a) => f(...a)
1286
1267
  });
1287
1268
  return;
1288
1269
  }
1289
- } catch (err) {
1290
- (0, import_log2.log)("initiation error: send offer", {
1291
- err,
1292
- topic: this.topic,
1293
- peerId: this.localPeerId,
1294
- remoteId: this.id
1295
- }, {
1296
- F: __dxlog_file2,
1297
- L: 197,
1298
- S: this,
1299
- C: (f, a) => f(...a)
1300
- });
1301
- await connection.abort(err);
1302
- throw err;
1303
- } finally {
1304
- this.initiating = false;
1305
- }
1306
- try {
1307
1270
  if (!answer.accept) {
1308
1271
  this._callbacks.onRejected();
1309
1272
  return;
1310
1273
  }
1311
- } catch (err) {
1312
- (0, import_log2.log)("initiation error: accept answer", {
1313
- err,
1314
- topic: this.topic,
1315
- peerId: this.localPeerId,
1316
- remoteId: this.id
1317
- }, {
1318
- F: __dxlog_file2,
1319
- L: 210,
1320
- S: this,
1321
- C: (f, a) => f(...a)
1322
- });
1323
- await connection.abort(err);
1324
- throw err;
1325
- } finally {
1326
- this.initiating = false;
1327
- }
1328
- try {
1329
- (0, import_log2.log)("opening connection as initiator", void 0, {
1330
- F: __dxlog_file2,
1331
- L: 223,
1332
- S: this,
1333
- C: (f, a) => f(...a)
1334
- });
1335
1274
  await connection.openConnection();
1336
1275
  this._callbacks.onAccepted();
1337
1276
  } catch (err) {
1338
- (0, import_log2.log)("initiation error: open connection", {
1277
+ (0, import_log2.log)("initiation error", {
1339
1278
  err,
1340
1279
  topic: this.topic,
1341
1280
  peerId: this.localPeerId,
1342
1281
  remoteId: this.id
1343
1282
  }, {
1344
1283
  F: __dxlog_file2,
1345
- L: 227,
1346
- S: this,
1347
- C: (f, a) => f(...a)
1348
- });
1349
- import_log2.log.warn("closing connection due to unhandled error on openConnection", {
1350
- err
1351
- }, {
1352
- F: __dxlog_file2,
1353
- L: 234,
1284
+ L: 200,
1354
1285
  S: this,
1355
1286
  C: (f, a) => f(...a)
1356
1287
  });
1288
+ if (err instanceof import_protocols2.TimeoutError) {
1289
+ import_log2.log.warn("aborting connection due to signalling failure", void 0, {
1290
+ F: __dxlog_file2,
1291
+ L: 202,
1292
+ S: this,
1293
+ C: (f, a) => f(...a)
1294
+ });
1295
+ await connection.abort(err);
1296
+ }
1357
1297
  await this.closeConnection(err);
1358
1298
  throw err;
1359
1299
  } finally {
@@ -1373,13 +1313,13 @@ var Peer = class {
1373
1313
  sessionId
1374
1314
  }, {
1375
1315
  F: __dxlog_file2,
1376
- L: 248,
1316
+ L: 218,
1377
1317
  S: this,
1378
1318
  C: (f, a) => f(...a)
1379
1319
  });
1380
1320
  (0, import_invariant2.invariant)(!this.connection, "Already connected.", {
1381
1321
  F: __dxlog_file2,
1382
- L: 255,
1322
+ L: 225,
1383
1323
  S: this,
1384
1324
  A: [
1385
1325
  "!this.connection",
@@ -1415,7 +1355,7 @@ var Peer = class {
1415
1355
  initiator
1416
1356
  }, {
1417
1357
  F: __dxlog_file2,
1418
- L: 274,
1358
+ L: 244,
1419
1359
  S: this,
1420
1360
  C: (f, a) => f(...a)
1421
1361
  });
@@ -1428,14 +1368,14 @@ var Peer = class {
1428
1368
  initiator
1429
1369
  }, {
1430
1370
  F: __dxlog_file2,
1431
- L: 283,
1371
+ L: 253,
1432
1372
  S: this,
1433
1373
  C: (f, a) => f(...a)
1434
1374
  });
1435
1375
  this._connectionLimiter.doneConnecting(sessionId);
1436
1376
  (0, import_invariant2.invariant)(this.connection === connection, "Connection mismatch (race condition).", {
1437
1377
  F: __dxlog_file2,
1438
- L: 288,
1378
+ L: 258,
1439
1379
  S: this,
1440
1380
  A: [
1441
1381
  "this.connection === connection",
@@ -1450,7 +1390,7 @@ var Peer = class {
1450
1390
  initiator
1451
1391
  }, {
1452
1392
  F: __dxlog_file2,
1453
- L: 290,
1393
+ L: 260,
1454
1394
  S: this,
1455
1395
  C: (f, a) => f(...a)
1456
1396
  });
@@ -1477,7 +1417,7 @@ var Peer = class {
1477
1417
  void this._connectionCtx?.dispose();
1478
1418
  this._connectionCtx = this._ctx.derive();
1479
1419
  connection.errors.handle((err) => {
1480
- import_log2.log.warn("connection error, closing", {
1420
+ import_log2.log.warn("connection error", {
1481
1421
  topic: this.topic,
1482
1422
  peerId: this.localPeerId,
1483
1423
  remoteId: this.id,
@@ -1485,7 +1425,7 @@ var Peer = class {
1485
1425
  err
1486
1426
  }, {
1487
1427
  F: __dxlog_file2,
1488
- L: 330,
1428
+ L: 300,
1489
1429
  S: this,
1490
1430
  C: (f, a) => f(...a)
1491
1431
  });
@@ -1498,7 +1438,7 @@ var Peer = class {
1498
1438
  err
1499
1439
  }, {
1500
1440
  F: __dxlog_file2,
1501
- L: 337,
1441
+ L: 301,
1502
1442
  S: this,
1503
1443
  C: (f, a) => f(...a)
1504
1444
  });
@@ -1517,7 +1457,7 @@ var Peer = class {
1517
1457
  sessionId: connection.sessionId
1518
1458
  }, {
1519
1459
  F: __dxlog_file2,
1520
- L: 362,
1460
+ L: 326,
1521
1461
  S: this,
1522
1462
  C: (f, a) => f(...a)
1523
1463
  });
@@ -1527,7 +1467,7 @@ var Peer = class {
1527
1467
  sessionId: connection.sessionId
1528
1468
  }, {
1529
1469
  F: __dxlog_file2,
1530
- L: 368,
1470
+ L: 332,
1531
1471
  S: this,
1532
1472
  C: (f, a) => f(...a)
1533
1473
  });
@@ -1538,7 +1478,7 @@ var Peer = class {
1538
1478
  message
1539
1479
  }, {
1540
1480
  F: __dxlog_file2,
1541
- L: 373,
1481
+ L: 337,
1542
1482
  S: this,
1543
1483
  C: (f, a) => f(...a)
1544
1484
  });
@@ -1546,18 +1486,18 @@ var Peer = class {
1546
1486
  }
1547
1487
  await this.connection.signal(message);
1548
1488
  }
1549
- async destroy(reason) {
1489
+ async destroy() {
1550
1490
  await this._ctx.dispose();
1551
1491
  (0, import_log2.log)("Destroying peer", {
1552
1492
  peerId: this.id,
1553
1493
  topic: this.topic
1554
1494
  }, {
1555
1495
  F: __dxlog_file2,
1556
- L: 383,
1496
+ L: 347,
1557
1497
  S: this,
1558
1498
  C: (f, a) => f(...a)
1559
1499
  });
1560
- await this?.connection?.close(reason);
1500
+ await this?.connection?.close();
1561
1501
  }
1562
1502
  };
1563
1503
  _ts_decorate2([
@@ -1930,7 +1870,7 @@ var Swarm = class {
1930
1870
  this._listeningHandle = void 0;
1931
1871
  await this._ctx.dispose();
1932
1872
  await this._topology.destroy();
1933
- await Promise.all(Array.from(this._peers.keys()).map((key) => this._destroyPeer(key, "swarm destroyed")));
1873
+ await Promise.all(Array.from(this._peers.keys()).map((key) => this._destroyPeer(key)));
1934
1874
  (0, import_log4.log)("destroyed", void 0, {
1935
1875
  F: __dxlog_file4,
1936
1876
  L: 148,
@@ -2002,22 +1942,13 @@ var Swarm = class {
2002
1942
  if (peer) {
2003
1943
  peer.advertizing = false;
2004
1944
  if (peer.connection?.state !== ConnectionState.CONNECTED) {
2005
- void this._destroyPeer(peer.id, "peer left").catch((err) => import_log4.log.catch(err, void 0, {
1945
+ void this._destroyPeer(peer.id).catch((err) => import_log4.log.catch(err, void 0, {
2006
1946
  F: __dxlog_file4,
2007
1947
  L: 189,
2008
1948
  S: this,
2009
1949
  C: (f, a) => f(...a)
2010
1950
  }));
2011
1951
  }
2012
- } else {
2013
- (0, import_log4.log)("received peerLeft but no peer found", {
2014
- peer: swarmEvent.peerLeft.peer
2015
- }, {
2016
- F: __dxlog_file4,
2017
- L: 192,
2018
- S: this,
2019
- C: (f, a) => f(...a)
2020
- });
2021
1952
  }
2022
1953
  }
2023
1954
  this._topology.update();
@@ -2027,14 +1958,14 @@ var Swarm = class {
2027
1958
  message
2028
1959
  }, {
2029
1960
  F: __dxlog_file4,
2030
- L: 201,
1961
+ L: 199,
2031
1962
  S: this,
2032
1963
  C: (f, a) => f(...a)
2033
1964
  });
2034
1965
  if (this._ctx.disposed) {
2035
1966
  (0, import_log4.log)("ignored for disposed swarm", void 0, {
2036
1967
  F: __dxlog_file4,
2037
- L: 203,
1968
+ L: 201,
2038
1969
  S: this,
2039
1970
  C: (f, a) => f(...a)
2040
1971
  });
@@ -2044,7 +1975,7 @@ var Swarm = class {
2044
1975
  }
2045
1976
  (0, import_invariant4.invariant)(message.author, void 0, {
2046
1977
  F: __dxlog_file4,
2047
- L: 208,
1978
+ L: 206,
2048
1979
  S: this,
2049
1980
  A: [
2050
1981
  "message.author",
@@ -2056,7 +1987,7 @@ var Swarm = class {
2056
1987
  message
2057
1988
  }, {
2058
1989
  F: __dxlog_file4,
2059
- L: 210,
1990
+ L: 208,
2060
1991
  S: this,
2061
1992
  C: (f, a) => f(...a)
2062
1993
  });
@@ -2069,7 +2000,7 @@ var Swarm = class {
2069
2000
  message
2070
2001
  }, {
2071
2002
  F: __dxlog_file4,
2072
- L: 214,
2003
+ L: 212,
2073
2004
  S: this,
2074
2005
  C: (f, a) => f(...a)
2075
2006
  });
@@ -2087,14 +2018,14 @@ var Swarm = class {
2087
2018
  message
2088
2019
  }, {
2089
2020
  F: __dxlog_file4,
2090
- L: 225,
2021
+ L: 223,
2091
2022
  S: this,
2092
2023
  C: (f, a) => f(...a)
2093
2024
  });
2094
2025
  if (this._ctx.disposed) {
2095
2026
  import_log4.log.info("ignored for offline swarm", void 0, {
2096
2027
  F: __dxlog_file4,
2097
- L: 227,
2028
+ L: 225,
2098
2029
  S: this,
2099
2030
  C: (f, a) => f(...a)
2100
2031
  });
@@ -2102,7 +2033,7 @@ var Swarm = class {
2102
2033
  }
2103
2034
  (0, import_invariant4.invariant)(message.recipient?.equals(this._ownPeerId), `Invalid signal peer id expected=${this.ownPeerId}, actual=${message.recipient}`, {
2104
2035
  F: __dxlog_file4,
2105
- L: 230,
2036
+ L: 228,
2106
2037
  S: this,
2107
2038
  A: [
2108
2039
  "message.recipient?.equals(this._ownPeerId)",
@@ -2111,7 +2042,7 @@ var Swarm = class {
2111
2042
  });
2112
2043
  (0, import_invariant4.invariant)(message.topic?.equals(this._topic), void 0, {
2113
2044
  F: __dxlog_file4,
2114
- L: 234,
2045
+ L: 232,
2115
2046
  S: this,
2116
2047
  A: [
2117
2048
  "message.topic?.equals(this._topic)",
@@ -2120,7 +2051,7 @@ var Swarm = class {
2120
2051
  });
2121
2052
  (0, import_invariant4.invariant)(message.author, void 0, {
2122
2053
  F: __dxlog_file4,
2123
- L: 235,
2054
+ L: 233,
2124
2055
  S: this,
2125
2056
  A: [
2126
2057
  "message.author",
@@ -2135,7 +2066,7 @@ var Swarm = class {
2135
2066
  await this._ctx.dispose();
2136
2067
  await Promise.all([
2137
2068
  ...this._peers.keys()
2138
- ].map((peerId) => this._destroyPeer(peerId, "goOffline")));
2069
+ ].map((peerId) => this._destroyPeer(peerId)));
2139
2070
  }
2140
2071
  // For debug purposes
2141
2072
  async goOnline() {
@@ -2153,22 +2084,14 @@ var Swarm = class {
2153
2084
  },
2154
2085
  onDisconnected: async () => {
2155
2086
  if (!peer.advertizing) {
2156
- await this._destroyPeer(peer.id, "peer disconnected");
2087
+ await this._destroyPeer(peer.id);
2157
2088
  }
2158
2089
  this.disconnected.emit(peerId);
2159
2090
  this._topology.update();
2160
2091
  },
2161
2092
  onRejected: () => {
2162
2093
  if (this._peers.has(peerId)) {
2163
- (0, import_log4.log)("peer rejected connection", {
2164
- peerId
2165
- }, {
2166
- F: __dxlog_file4,
2167
- L: 284,
2168
- S: this,
2169
- C: (f, a) => f(...a)
2170
- });
2171
- void this._destroyPeer(peerId, "peer rejected connection");
2094
+ void this._destroyPeer(peerId);
2172
2095
  }
2173
2096
  },
2174
2097
  onAccepted: () => {
@@ -2185,17 +2108,17 @@ var Swarm = class {
2185
2108
  }
2186
2109
  return peer;
2187
2110
  }
2188
- async _destroyPeer(peerId, reason) {
2111
+ async _destroyPeer(peerId) {
2189
2112
  (0, import_invariant4.invariant)(this._peers.has(peerId), void 0, {
2190
2113
  F: __dxlog_file4,
2191
- L: 306,
2114
+ L: 303,
2192
2115
  S: this,
2193
2116
  A: [
2194
2117
  "this._peers.has(peerId)",
2195
2118
  ""
2196
2119
  ]
2197
2120
  });
2198
- await this._peers.get(peerId).destroy(new Error(reason));
2121
+ await this._peers.get(peerId).destroy();
2199
2122
  this._peers.delete(peerId);
2200
2123
  }
2201
2124
  _getSwarmController() {
@@ -2215,7 +2138,7 @@ var Swarm = class {
2215
2138
  } catch (err) {
2216
2139
  (0, import_log4.log)("initiation error", err, {
2217
2140
  F: __dxlog_file4,
2218
- L: 332,
2141
+ L: 329,
2219
2142
  S: this,
2220
2143
  C: (f, a) => f(...a)
2221
2144
  });
@@ -2243,7 +2166,7 @@ var Swarm = class {
2243
2166
  remoteId
2244
2167
  }, {
2245
2168
  F: __dxlog_file4,
2246
- L: 359,
2169
+ L: 356,
2247
2170
  S: this,
2248
2171
  C: (f, a) => f(...a)
2249
2172
  });
@@ -2260,7 +2183,7 @@ var Swarm = class {
2260
2183
  remoteId
2261
2184
  }, {
2262
2185
  F: __dxlog_file4,
2263
- L: 373,
2186
+ L: 370,
2264
2187
  S: this,
2265
2188
  C: (f, a) => f(...a)
2266
2189
  });
@@ -2270,7 +2193,7 @@ var Swarm = class {
2270
2193
  remoteId
2271
2194
  }, {
2272
2195
  F: __dxlog_file4,
2273
- L: 376,
2196
+ L: 373,
2274
2197
  S: this,
2275
2198
  C: (f, a) => f(...a)
2276
2199
  });