@dxos/network-manager 0.1.58-main.f4192cb → 0.1.58-main.f69fa2f

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.
@@ -842,7 +842,7 @@ var Connection = class {
842
842
  this.closeReason = err?.message;
843
843
  }
844
844
  if (err instanceof import_protocols.ConnectionResetError) {
845
- (0, import_log2.log)("aborting due to transport ConnectionResetError", void 0, {
845
+ import_log2.log.warn("aborting due to transport ConnectionResetError", void 0, {
846
846
  F: __dxlog_file2,
847
847
  L: 197,
848
848
  S: this,
@@ -850,7 +850,7 @@ var Connection = class {
850
850
  });
851
851
  this.abort().catch((err2) => this.errors.raise(err2));
852
852
  } else if (err instanceof import_protocols.ConnectivityError) {
853
- (0, import_log2.log)("aborting due to transport ConnectivityError", void 0, {
853
+ import_log2.log.warn("aborting due to transport ConnectivityError", void 0, {
854
854
  F: __dxlog_file2,
855
855
  L: 200,
856
856
  S: this,
@@ -858,7 +858,7 @@ var Connection = class {
858
858
  });
859
859
  this.abort().catch((err2) => this.errors.raise(err2));
860
860
  } else if (err instanceof import_protocols.UnknownProtocolError) {
861
- (0, import_log2.log)("unsure what to do for UnknownProtocolError", {
861
+ import_log2.log.warn("unsure what to do with UnknownProtocolError, will keep on truckin", {
862
862
  err
863
863
  }, {
864
864
  F: __dxlog_file2,
@@ -889,14 +889,14 @@ var Connection = class {
889
889
  err
890
890
  }, {
891
891
  F: __dxlog_file2,
892
- L: 224,
892
+ L: 225,
893
893
  S: this,
894
894
  C: (f, a) => f(...a)
895
895
  });
896
896
  if (this._state === ConnectionState.CLOSED || this._state === ConnectionState.ABORTED) {
897
897
  (0, import_log2.log)(`abort ignored: already ${this._state}`, this.closeReason, {
898
898
  F: __dxlog_file2,
899
- L: 226,
899
+ L: 227,
900
900
  S: this,
901
901
  C: (f, a) => f(...a)
902
902
  });
@@ -912,7 +912,7 @@ var Connection = class {
912
912
  proto: this._protocol
913
913
  }, {
914
914
  F: __dxlog_file2,
915
- L: 239,
915
+ L: 240,
916
916
  S: this,
917
917
  C: (f, a) => f(...a)
918
918
  });
@@ -920,7 +920,7 @@ var Connection = class {
920
920
  } catch (err2) {
921
921
  import_log2.log.catch(err2, void 0, {
922
922
  F: __dxlog_file2,
923
- L: 242,
923
+ L: 243,
924
924
  S: this,
925
925
  C: (f, a) => f(...a)
926
926
  });
@@ -930,7 +930,7 @@ var Connection = class {
930
930
  } catch (err2) {
931
931
  import_log2.log.catch(err2, void 0, {
932
932
  F: __dxlog_file2,
933
- L: 249,
933
+ L: 250,
934
934
  S: this,
935
935
  C: (f, a) => f(...a)
936
936
  });
@@ -940,7 +940,7 @@ var Connection = class {
940
940
  } catch (err2) {
941
941
  import_log2.log.catch(err2, void 0, {
942
942
  F: __dxlog_file2,
943
- L: 255,
943
+ L: 256,
944
944
  S: this,
945
945
  C: (f, a) => f(...a)
946
946
  });
@@ -961,7 +961,7 @@ var Connection = class {
961
961
  peerId: this.ownId
962
962
  }, {
963
963
  F: __dxlog_file2,
964
- L: 277,
964
+ L: 278,
965
965
  S: this,
966
966
  C: (f, a) => f(...a)
967
967
  });
@@ -971,7 +971,7 @@ var Connection = class {
971
971
  } catch (err2) {
972
972
  import_log2.log.catch(err2, void 0, {
973
973
  F: __dxlog_file2,
974
- L: 284,
974
+ L: 285,
975
975
  S: this,
976
976
  C: (f, a) => f(...a)
977
977
  });
@@ -981,7 +981,7 @@ var Connection = class {
981
981
  } catch (err2) {
982
982
  import_log2.log.catch(err2, void 0, {
983
983
  F: __dxlog_file2,
984
- L: 291,
984
+ L: 292,
985
985
  S: this,
986
986
  C: (f, a) => f(...a)
987
987
  });
@@ -991,7 +991,7 @@ var Connection = class {
991
991
  peerId: this.ownId
992
992
  }, {
993
993
  F: __dxlog_file2,
994
- L: 295,
994
+ L: 296,
995
995
  S: this,
996
996
  C: (f, a) => f(...a)
997
997
  });
@@ -1034,7 +1034,7 @@ var Connection = class {
1034
1034
  err
1035
1035
  }, {
1036
1036
  F: __dxlog_file2,
1037
- L: 332,
1037
+ L: 333,
1038
1038
  S: this,
1039
1039
  C: (f, a) => f(...a)
1040
1040
  });
@@ -1047,7 +1047,7 @@ var Connection = class {
1047
1047
  async signal(msg) {
1048
1048
  (0, import_invariant.invariant)(msg.sessionId, void 0, {
1049
1049
  F: __dxlog_file2,
1050
- L: 341,
1050
+ L: 342,
1051
1051
  S: this,
1052
1052
  A: [
1053
1053
  "msg.sessionId",
@@ -1057,7 +1057,7 @@ var Connection = class {
1057
1057
  if (!msg.sessionId.equals(this.sessionId)) {
1058
1058
  (0, import_log2.log)("dropping signal for incorrect session id", void 0, {
1059
1059
  F: __dxlog_file2,
1060
- L: 343,
1060
+ L: 344,
1061
1061
  S: this,
1062
1062
  C: (f, a) => f(...a)
1063
1063
  });
@@ -1065,7 +1065,7 @@ var Connection = class {
1065
1065
  }
1066
1066
  (0, import_invariant.invariant)(msg.data.signal || msg.data.signalBatch, void 0, {
1067
1067
  F: __dxlog_file2,
1068
- L: 346,
1068
+ L: 347,
1069
1069
  S: this,
1070
1070
  A: [
1071
1071
  "msg.data.signal || msg.data.signalBatch",
@@ -1074,7 +1074,7 @@ var Connection = class {
1074
1074
  });
1075
1075
  (0, import_invariant.invariant)(msg.author?.equals(this.remoteId), void 0, {
1076
1076
  F: __dxlog_file2,
1077
- L: 347,
1077
+ L: 348,
1078
1078
  S: this,
1079
1079
  A: [
1080
1080
  "msg.author?.equals(this.remoteId)",
@@ -1083,7 +1083,7 @@ var Connection = class {
1083
1083
  });
1084
1084
  (0, import_invariant.invariant)(msg.recipient?.equals(this.ownId), void 0, {
1085
1085
  F: __dxlog_file2,
1086
- L: 348,
1086
+ L: 349,
1087
1087
  S: this,
1088
1088
  A: [
1089
1089
  "msg.recipient?.equals(this.ownId)",
@@ -1107,7 +1107,7 @@ var Connection = class {
1107
1107
  msg: msg.data
1108
1108
  }, {
1109
1109
  F: __dxlog_file2,
1110
- L: 357,
1110
+ L: 358,
1111
1111
  S: this,
1112
1112
  C: (f, a) => f(...a)
1113
1113
  });
@@ -1115,7 +1115,7 @@ var Connection = class {
1115
1115
  } else {
1116
1116
  (0, import_invariant.invariant)(this._transport, "Connection not ready to accept signals.", {
1117
1117
  F: __dxlog_file2,
1118
- L: 360,
1118
+ L: 361,
1119
1119
  S: this,
1120
1120
  A: [
1121
1121
  "this._transport",
@@ -1128,7 +1128,7 @@ var Connection = class {
1128
1128
  msg: msg.data
1129
1129
  }, {
1130
1130
  F: __dxlog_file2,
1131
- L: 361,
1131
+ L: 362,
1132
1132
  S: this,
1133
1133
  C: (f, a) => f(...a)
1134
1134
  });
@@ -1146,13 +1146,13 @@ var Connection = class {
1146
1146
  peerId: this.ownId
1147
1147
  }, {
1148
1148
  F: __dxlog_file2,
1149
- L: 372,
1149
+ L: 373,
1150
1150
  S: this,
1151
1151
  C: (f, a) => f(...a)
1152
1152
  });
1153
1153
  (0, import_invariant.invariant)(state !== this._state, "Already in this state.", {
1154
1154
  F: __dxlog_file2,
1155
- L: 373,
1155
+ L: 374,
1156
1156
  S: this,
1157
1157
  A: [
1158
1158
  "state !== this._state",
@@ -1227,6 +1227,20 @@ var Peer = class {
1227
1227
  */
1228
1228
  async onOffer(message) {
1229
1229
  const remoteId = message.author;
1230
+ if (this.connection && ![
1231
+ ConnectionState.CREATED,
1232
+ ConnectionState.INITIAL
1233
+ ].includes(this.connection.state)) {
1234
+ import_log3.log.info(`received offer when connection already in ${this.connection.state} state`, void 0, {
1235
+ F: __dxlog_file3,
1236
+ L: 112,
1237
+ S: this,
1238
+ C: (f, a) => f(...a)
1239
+ });
1240
+ return {
1241
+ accept: false
1242
+ };
1243
+ }
1230
1244
  if (this.connection || this.initiating) {
1231
1245
  if (remoteId.toHex() < this.localPeerId.toHex()) {
1232
1246
  (0, import_log3.log)("close local connection", {
@@ -1236,7 +1250,7 @@ var Peer = class {
1236
1250
  sessionId: this.connection?.sessionId
1237
1251
  }, {
1238
1252
  F: __dxlog_file3,
1239
- L: 117,
1253
+ L: 121,
1240
1254
  S: this,
1241
1255
  C: (f, a) => f(...a)
1242
1256
  });
@@ -1253,7 +1267,7 @@ var Peer = class {
1253
1267
  if (!this.connection) {
1254
1268
  (0, import_invariant2.invariant)(message.sessionId, void 0, {
1255
1269
  F: __dxlog_file3,
1256
- L: 137,
1270
+ L: 141,
1257
1271
  S: this,
1258
1272
  A: [
1259
1273
  "message.sessionId",
@@ -1274,7 +1288,7 @@ var Peer = class {
1274
1288
  err
1275
1289
  }, {
1276
1290
  F: __dxlog_file3,
1277
- L: 147,
1291
+ L: 151,
1278
1292
  S: this,
1279
1293
  C: (f, a) => f(...a)
1280
1294
  });
@@ -1296,7 +1310,7 @@ var Peer = class {
1296
1310
  async initiateConnection() {
1297
1311
  (0, import_invariant2.invariant)(!this.initiating, "Initiation in progress.", {
1298
1312
  F: __dxlog_file3,
1299
- L: 164,
1313
+ L: 168,
1300
1314
  S: this,
1301
1315
  A: [
1302
1316
  "!this.initiating",
@@ -1305,7 +1319,7 @@ var Peer = class {
1305
1319
  });
1306
1320
  (0, import_invariant2.invariant)(!this.connection, "Already connected.", {
1307
1321
  F: __dxlog_file3,
1308
- L: 165,
1322
+ L: 169,
1309
1323
  S: this,
1310
1324
  A: [
1311
1325
  "!this.connection",
@@ -1320,7 +1334,7 @@ var Peer = class {
1320
1334
  sessionId
1321
1335
  }, {
1322
1336
  F: __dxlog_file3,
1323
- L: 167,
1337
+ L: 171,
1324
1338
  S: this,
1325
1339
  C: (f, a) => f(...a)
1326
1340
  });
@@ -1345,14 +1359,14 @@ var Peer = class {
1345
1359
  remoteId: this.id
1346
1360
  }, {
1347
1361
  F: __dxlog_file3,
1348
- L: 183,
1362
+ L: 187,
1349
1363
  S: this,
1350
1364
  C: (f, a) => f(...a)
1351
1365
  });
1352
1366
  if (connection.state !== ConnectionState.INITIAL) {
1353
1367
  (0, import_log3.log)("ignoring response", void 0, {
1354
1368
  F: __dxlog_file3,
1355
- L: 185,
1369
+ L: 189,
1356
1370
  S: this,
1357
1371
  C: (f, a) => f(...a)
1358
1372
  });
@@ -1372,11 +1386,17 @@ var Peer = class {
1372
1386
  remoteId: this.id
1373
1387
  }, {
1374
1388
  F: __dxlog_file3,
1375
- L: 196,
1389
+ L: 200,
1376
1390
  S: this,
1377
1391
  C: (f, a) => f(...a)
1378
1392
  });
1379
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
+ });
1380
1400
  await connection.abort(err);
1381
1401
  }
1382
1402
  await this.closeConnection(err);
@@ -1398,13 +1418,13 @@ var Peer = class {
1398
1418
  sessionId
1399
1419
  }, {
1400
1420
  F: __dxlog_file3,
1401
- L: 213,
1421
+ L: 218,
1402
1422
  S: this,
1403
1423
  C: (f, a) => f(...a)
1404
1424
  });
1405
1425
  (0, import_invariant2.invariant)(!this.connection, "Already connected.", {
1406
1426
  F: __dxlog_file3,
1407
- L: 220,
1427
+ L: 225,
1408
1428
  S: this,
1409
1429
  A: [
1410
1430
  "!this.connection",
@@ -1440,7 +1460,7 @@ var Peer = class {
1440
1460
  initiator
1441
1461
  }, {
1442
1462
  F: __dxlog_file3,
1443
- L: 239,
1463
+ L: 244,
1444
1464
  S: this,
1445
1465
  C: (f, a) => f(...a)
1446
1466
  });
@@ -1453,14 +1473,14 @@ var Peer = class {
1453
1473
  initiator
1454
1474
  }, {
1455
1475
  F: __dxlog_file3,
1456
- L: 248,
1476
+ L: 253,
1457
1477
  S: this,
1458
1478
  C: (f, a) => f(...a)
1459
1479
  });
1460
1480
  this._connectionLimiter.doneConnecting(sessionId);
1461
1481
  (0, import_invariant2.invariant)(this.connection === connection, "Connection mismatch (race condition).", {
1462
1482
  F: __dxlog_file3,
1463
- L: 253,
1483
+ L: 258,
1464
1484
  S: this,
1465
1485
  A: [
1466
1486
  "this.connection === connection",
@@ -1475,7 +1495,7 @@ var Peer = class {
1475
1495
  initiator
1476
1496
  }, {
1477
1497
  F: __dxlog_file3,
1478
- L: 255,
1498
+ L: 260,
1479
1499
  S: this,
1480
1500
  C: (f, a) => f(...a)
1481
1501
  });
@@ -1510,7 +1530,7 @@ var Peer = class {
1510
1530
  err
1511
1531
  }, {
1512
1532
  F: __dxlog_file3,
1513
- L: 295,
1533
+ L: 300,
1514
1534
  S: this,
1515
1535
  C: (f, a) => f(...a)
1516
1536
  });
@@ -1523,7 +1543,7 @@ var Peer = class {
1523
1543
  err
1524
1544
  }, {
1525
1545
  F: __dxlog_file3,
1526
- L: 296,
1546
+ L: 301,
1527
1547
  S: this,
1528
1548
  C: (f, a) => f(...a)
1529
1549
  });
@@ -1542,7 +1562,7 @@ var Peer = class {
1542
1562
  sessionId: connection.sessionId
1543
1563
  }, {
1544
1564
  F: __dxlog_file3,
1545
- L: 321,
1565
+ L: 326,
1546
1566
  S: this,
1547
1567
  C: (f, a) => f(...a)
1548
1568
  });
@@ -1552,7 +1572,7 @@ var Peer = class {
1552
1572
  sessionId: connection.sessionId
1553
1573
  }, {
1554
1574
  F: __dxlog_file3,
1555
- L: 327,
1575
+ L: 332,
1556
1576
  S: this,
1557
1577
  C: (f, a) => f(...a)
1558
1578
  });
@@ -1563,7 +1583,7 @@ var Peer = class {
1563
1583
  message
1564
1584
  }, {
1565
1585
  F: __dxlog_file3,
1566
- L: 332,
1586
+ L: 337,
1567
1587
  S: this,
1568
1588
  C: (f, a) => f(...a)
1569
1589
  });
@@ -1578,7 +1598,7 @@ var Peer = class {
1578
1598
  topic: this.topic
1579
1599
  }, {
1580
1600
  F: __dxlog_file3,
1581
- L: 342,
1601
+ L: 347,
1582
1602
  S: this,
1583
1603
  C: (f, a) => f(...a)
1584
1604
  });
@@ -3107,24 +3127,28 @@ var SimplePeerTransport = class {
3107
3127
  switch (err.code) {
3108
3128
  case "ERR_WEBRTC_SUPPORT":
3109
3129
  this.errors.raise(new import_protocols7.ProtocolError("WebRTC not supported", err));
3130
+ break;
3110
3131
  case "ERR_ICE_CONNECTION_FAILURE":
3111
3132
  case "ERR_DATA_CHANNEL":
3112
3133
  case "ERR_CONNECTION_FAILURE":
3113
3134
  case "ERR_SIGNALING":
3114
3135
  this.errors.raise(new import_protocols7.ConnectivityError("unknown communication failure", err));
3136
+ break;
3115
3137
  case "ERR_CREATE_OFFER":
3116
3138
  case "ERR_CREATE_ANSWER":
3117
3139
  case "ERR_SET_LOCAL_DESCRIPTION":
3118
3140
  case "ERR_SET_REMOTE_DESCRIPTION":
3119
3141
  case "ERR_ADD_ICE_CANDIDATE":
3120
3142
  this.errors.raise(new import_protocols7.UnknownProtocolError("unknown simple-peer library failure", err));
3143
+ break;
3121
3144
  default:
3122
3145
  this.errors.raise(new Error("unknown simple-peer error"));
3146
+ break;
3123
3147
  }
3124
3148
  } else {
3125
3149
  import_log12.log.info("unknown peer connection error", err, {
3126
3150
  F: __dxlog_file11,
3127
- L: 96,
3151
+ L: 101,
3128
3152
  S: this,
3129
3153
  C: (f, a) => f(...a)
3130
3154
  });
@@ -3138,7 +3162,7 @@ var SimplePeerTransport = class {
3138
3162
  stats
3139
3163
  }, {
3140
3164
  F: __dxlog_file11,
3141
- L: 104,
3165
+ L: 109,
3142
3166
  S: this,
3143
3167
  C: (f, a) => f(...a)
3144
3168
  });
@@ -3147,7 +3171,7 @@ var SimplePeerTransport = class {
3147
3171
  } catch (err2) {
3148
3172
  import_log12.log.catch(err2, void 0, {
3149
3173
  F: __dxlog_file11,
3150
- L: 111,
3174
+ L: 116,
3151
3175
  S: this,
3152
3176
  C: (f, a) => f(...a)
3153
3177
  });
@@ -3158,7 +3182,7 @@ var SimplePeerTransport = class {
3158
3182
  id: this._instanceId
3159
3183
  }), {
3160
3184
  F: __dxlog_file11,
3161
- L: 116,
3185
+ L: 121,
3162
3186
  S: this,
3163
3187
  C: (f, a) => f(...a)
3164
3188
  });
@@ -3166,7 +3190,7 @@ var SimplePeerTransport = class {
3166
3190
  async destroy() {
3167
3191
  (0, import_log12.log)("closing...", void 0, {
3168
3192
  F: __dxlog_file11,
3169
- L: 120,
3193
+ L: 125,
3170
3194
  S: this,
3171
3195
  C: (f, a) => f(...a)
3172
3196
  });
@@ -3176,7 +3200,7 @@ var SimplePeerTransport = class {
3176
3200
  this.closed.emit();
3177
3201
  (0, import_log12.log)("closed", void 0, {
3178
3202
  F: __dxlog_file11,
3179
- L: 125,
3203
+ L: 130,
3180
3204
  S: this,
3181
3205
  C: (f, a) => f(...a)
3182
3206
  });
@@ -3278,7 +3302,8 @@ var SimplePeerTransportService = class {
3278
3302
  const transportState = {
3279
3303
  transport,
3280
3304
  stream: duplex,
3281
- writeCallbacks: []
3305
+ writeCallbacks: [],
3306
+ state: "OPEN"
3282
3307
  };
3283
3308
  ready();
3284
3309
  this.transports.set(request.proxyId, transportState);
@@ -3288,7 +3313,7 @@ var SimplePeerTransportService = class {
3288
3313
  async sendSignal({ proxyId, signal }) {
3289
3314
  (0, import_invariant11.invariant)(this.transports.has(proxyId), void 0, {
3290
3315
  F: __dxlog_file12,
3291
- L: 110,
3316
+ L: 112,
3292
3317
  S: this,
3293
3318
  A: [
3294
3319
  "this.transports.has(proxyId)",
@@ -3298,9 +3323,17 @@ var SimplePeerTransportService = class {
3298
3323
  await this.transports.get(proxyId).transport.signal(signal);
3299
3324
  }
3300
3325
  async sendData({ proxyId, payload }) {
3326
+ if (this.transports.get(proxyId)?.state !== "OPEN") {
3327
+ import_log13.log.debug("transport is closed", void 0, {
3328
+ F: __dxlog_file12,
3329
+ L: 118,
3330
+ S: this,
3331
+ C: (f, a) => f(...a)
3332
+ });
3333
+ }
3301
3334
  (0, import_invariant11.invariant)(this.transports.has(proxyId), void 0, {
3302
3335
  F: __dxlog_file12,
3303
- L: 115,
3336
+ L: 120,
3304
3337
  S: this,
3305
3338
  A: [
3306
3339
  "this.transports.has(proxyId)",
@@ -3318,10 +3351,12 @@ var SimplePeerTransportService = class {
3318
3351
  async close({ proxyId }) {
3319
3352
  await this.transports.get(proxyId)?.transport.destroy();
3320
3353
  await this.transports.get(proxyId)?.stream.end();
3321
- this.transports.delete(proxyId);
3354
+ if (this.transports.get(proxyId)) {
3355
+ this.transports.get(proxyId).state = "CLOSED";
3356
+ }
3322
3357
  (0, import_log13.log)("Closed.", void 0, {
3323
3358
  F: __dxlog_file12,
3324
- L: 129,
3359
+ L: 136,
3325
3360
  S: this,
3326
3361
  C: (f, a) => f(...a)
3327
3362
  });