@dxos/network-manager 0.4.10-main.ec8b427 → 0.4.10-main.ef6fbc2

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.
@@ -26,8 +26,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var chunk_5D3NBEP2_exports = {};
30
- __export(chunk_5D3NBEP2_exports, {
29
+ var chunk_HUPX2JGP_exports = {};
30
+ __export(chunk_HUPX2JGP_exports, {
31
31
  Connection: () => Connection,
32
32
  ConnectionLimiter: () => ConnectionLimiter,
33
33
  ConnectionLog: () => ConnectionLog,
@@ -55,7 +55,7 @@ __export(chunk_5D3NBEP2_exports, {
55
55
  createSimplePeerTransportFactory: () => createSimplePeerTransportFactory,
56
56
  createTeleportProtocolFactory: () => createTeleportProtocolFactory
57
57
  });
58
- module.exports = __toCommonJS(chunk_5D3NBEP2_exports);
58
+ module.exports = __toCommonJS(chunk_HUPX2JGP_exports);
59
59
  var import_async = require("@dxos/async");
60
60
  var import_context = require("@dxos/context");
61
61
  var import_debug = require("@dxos/debug");
@@ -1452,7 +1452,7 @@ var Swarm = class {
1452
1452
  }
1453
1453
  }), {
1454
1454
  F: __dxlog_file4,
1455
- L: 88,
1455
+ L: 89,
1456
1456
  S: this,
1457
1457
  C: (f, a) => f(...a)
1458
1458
  });
@@ -1460,7 +1460,7 @@ var Swarm = class {
1460
1460
  peerId: _ownPeerId
1461
1461
  }, {
1462
1462
  F: __dxlog_file4,
1463
- L: 92,
1463
+ L: 93,
1464
1464
  S: this,
1465
1465
  C: (f, a) => f(...a)
1466
1466
  });
@@ -1475,7 +1475,7 @@ var Swarm = class {
1475
1475
  id: this._instanceId
1476
1476
  }), {
1477
1477
  F: __dxlog_file4,
1478
- L: 101,
1478
+ L: 102,
1479
1479
  S: this,
1480
1480
  C: (f, a) => f(...a)
1481
1481
  });
@@ -1498,7 +1498,7 @@ var Swarm = class {
1498
1498
  async open() {
1499
1499
  (0, import_invariant3.invariant)(!this._listeningHandle, void 0, {
1500
1500
  F: __dxlog_file4,
1501
- L: 128,
1501
+ L: 129,
1502
1502
  S: this,
1503
1503
  A: [
1504
1504
  "!this._listeningHandle",
@@ -1513,7 +1513,7 @@ var Swarm = class {
1513
1513
  err
1514
1514
  }, {
1515
1515
  F: __dxlog_file4,
1516
- L: 136,
1516
+ L: 137,
1517
1517
  S: this,
1518
1518
  C: (f, a) => f(...a)
1519
1519
  }));
@@ -1523,7 +1523,7 @@ var Swarm = class {
1523
1523
  async destroy() {
1524
1524
  (0, import_log3.log)("destroying...", void 0, {
1525
1525
  F: __dxlog_file4,
1526
- L: 142,
1526
+ L: 143,
1527
1527
  S: this,
1528
1528
  C: (f, a) => f(...a)
1529
1529
  });
@@ -1534,7 +1534,7 @@ var Swarm = class {
1534
1534
  await Promise.all(Array.from(this._peers.keys()).map((key) => this._destroyPeer(key, "swarm destroyed")));
1535
1535
  (0, import_log3.log)("destroyed", void 0, {
1536
1536
  F: __dxlog_file4,
1537
- L: 149,
1537
+ L: 150,
1538
1538
  S: this,
1539
1539
  C: (f, a) => f(...a)
1540
1540
  });
@@ -1542,7 +1542,7 @@ var Swarm = class {
1542
1542
  async setTopology(topology) {
1543
1543
  (0, import_invariant3.invariant)(!this._ctx.disposed, "Swarm is offline", {
1544
1544
  F: __dxlog_file4,
1545
- L: 153,
1545
+ L: 154,
1546
1546
  S: this,
1547
1547
  A: [
1548
1548
  "!this._ctx.disposed",
@@ -1557,7 +1557,7 @@ var Swarm = class {
1557
1557
  topology: getClassName(topology)
1558
1558
  }, {
1559
1559
  F: __dxlog_file4,
1560
- L: 157,
1560
+ L: 158,
1561
1561
  S: this,
1562
1562
  C: (f, a) => f(...a)
1563
1563
  });
@@ -1571,14 +1571,14 @@ var Swarm = class {
1571
1571
  swarmEvent
1572
1572
  }, {
1573
1573
  F: __dxlog_file4,
1574
- L: 170,
1574
+ L: 171,
1575
1575
  S: this,
1576
1576
  C: (f, a) => f(...a)
1577
1577
  });
1578
1578
  if (this._ctx.disposed) {
1579
1579
  (0, import_log3.log)("swarm event ignored for disposed swarm", void 0, {
1580
1580
  F: __dxlog_file4,
1581
- L: 173,
1581
+ L: 174,
1582
1582
  S: this,
1583
1583
  C: (f, a) => f(...a)
1584
1584
  });
@@ -1590,7 +1590,7 @@ var Swarm = class {
1590
1590
  peerId
1591
1591
  }, {
1592
1592
  F: __dxlog_file4,
1593
- L: 179,
1593
+ L: 180,
1594
1594
  S: this,
1595
1595
  C: (f, a) => f(...a)
1596
1596
  });
@@ -1605,7 +1605,7 @@ var Swarm = class {
1605
1605
  if (peer.connection?.state !== ConnectionState.CONNECTED) {
1606
1606
  void this._destroyPeer(peer.id, "peer left").catch((err) => import_log3.log.catch(err, void 0, {
1607
1607
  F: __dxlog_file4,
1608
- L: 190,
1608
+ L: 191,
1609
1609
  S: this,
1610
1610
  C: (f, a) => f(...a)
1611
1611
  }));
@@ -1615,7 +1615,7 @@ var Swarm = class {
1615
1615
  peer: swarmEvent.peerLeft.peer
1616
1616
  }, {
1617
1617
  F: __dxlog_file4,
1618
- L: 193,
1618
+ L: 194,
1619
1619
  S: this,
1620
1620
  C: (f, a) => f(...a)
1621
1621
  });
@@ -1628,14 +1628,14 @@ var Swarm = class {
1628
1628
  message
1629
1629
  }, {
1630
1630
  F: __dxlog_file4,
1631
- L: 202,
1631
+ L: 203,
1632
1632
  S: this,
1633
1633
  C: (f, a) => f(...a)
1634
1634
  });
1635
1635
  if (this._ctx.disposed) {
1636
1636
  (0, import_log3.log)("ignored for disposed swarm", void 0, {
1637
1637
  F: __dxlog_file4,
1638
- L: 204,
1638
+ L: 205,
1639
1639
  S: this,
1640
1640
  C: (f, a) => f(...a)
1641
1641
  });
@@ -1645,7 +1645,7 @@ var Swarm = class {
1645
1645
  }
1646
1646
  (0, import_invariant3.invariant)(message.author, void 0, {
1647
1647
  F: __dxlog_file4,
1648
- L: 209,
1648
+ L: 210,
1649
1649
  S: this,
1650
1650
  A: [
1651
1651
  "message.author",
@@ -1657,7 +1657,7 @@ var Swarm = class {
1657
1657
  message
1658
1658
  }, {
1659
1659
  F: __dxlog_file4,
1660
- L: 211,
1660
+ L: 212,
1661
1661
  S: this,
1662
1662
  C: (f, a) => f(...a)
1663
1663
  });
@@ -1670,7 +1670,7 @@ var Swarm = class {
1670
1670
  message
1671
1671
  }, {
1672
1672
  F: __dxlog_file4,
1673
- L: 215,
1673
+ L: 216,
1674
1674
  S: this,
1675
1675
  C: (f, a) => f(...a)
1676
1676
  });
@@ -1688,14 +1688,14 @@ var Swarm = class {
1688
1688
  message
1689
1689
  }, {
1690
1690
  F: __dxlog_file4,
1691
- L: 226,
1691
+ L: 227,
1692
1692
  S: this,
1693
1693
  C: (f, a) => f(...a)
1694
1694
  });
1695
1695
  if (this._ctx.disposed) {
1696
1696
  import_log3.log.info("ignored for offline swarm", void 0, {
1697
1697
  F: __dxlog_file4,
1698
- L: 228,
1698
+ L: 229,
1699
1699
  S: this,
1700
1700
  C: (f, a) => f(...a)
1701
1701
  });
@@ -1703,7 +1703,7 @@ var Swarm = class {
1703
1703
  }
1704
1704
  (0, import_invariant3.invariant)(message.recipient?.equals(this._ownPeerId), `Invalid signal peer id expected=${this.ownPeerId}, actual=${message.recipient}`, {
1705
1705
  F: __dxlog_file4,
1706
- L: 231,
1706
+ L: 232,
1707
1707
  S: this,
1708
1708
  A: [
1709
1709
  "message.recipient?.equals(this._ownPeerId)",
@@ -1712,7 +1712,7 @@ var Swarm = class {
1712
1712
  });
1713
1713
  (0, import_invariant3.invariant)(message.topic?.equals(this._topic), void 0, {
1714
1714
  F: __dxlog_file4,
1715
- L: 235,
1715
+ L: 236,
1716
1716
  S: this,
1717
1717
  A: [
1718
1718
  "message.topic?.equals(this._topic)",
@@ -1721,7 +1721,7 @@ var Swarm = class {
1721
1721
  });
1722
1722
  (0, import_invariant3.invariant)(message.author, void 0, {
1723
1723
  F: __dxlog_file4,
1724
- L: 236,
1724
+ L: 237,
1725
1725
  S: this,
1726
1726
  A: [
1727
1727
  "message.author",
@@ -1765,7 +1765,7 @@ var Swarm = class {
1765
1765
  peerId
1766
1766
  }, {
1767
1767
  F: __dxlog_file4,
1768
- L: 285,
1768
+ L: 286,
1769
1769
  S: this,
1770
1770
  C: (f, a) => f(...a)
1771
1771
  });
@@ -1789,7 +1789,7 @@ var Swarm = class {
1789
1789
  async _destroyPeer(peerId, reason) {
1790
1790
  (0, import_invariant3.invariant)(this._peers.has(peerId), void 0, {
1791
1791
  F: __dxlog_file4,
1792
- L: 307,
1792
+ L: 308,
1793
1793
  S: this,
1794
1794
  A: [
1795
1795
  "this._peers.has(peerId)",
@@ -1816,7 +1816,7 @@ var Swarm = class {
1816
1816
  } catch (err) {
1817
1817
  (0, import_log3.log)("initiation error", err, {
1818
1818
  F: __dxlog_file4,
1819
- L: 333,
1819
+ L: 334,
1820
1820
  S: this,
1821
1821
  C: (f, a) => f(...a)
1822
1822
  });
@@ -1844,7 +1844,7 @@ var Swarm = class {
1844
1844
  remoteId
1845
1845
  }, {
1846
1846
  F: __dxlog_file4,
1847
- L: 360,
1847
+ L: 361,
1848
1848
  S: this,
1849
1849
  C: (f, a) => f(...a)
1850
1850
  });
@@ -1861,7 +1861,7 @@ var Swarm = class {
1861
1861
  remoteId
1862
1862
  }, {
1863
1863
  F: __dxlog_file4,
1864
- L: 374,
1864
+ L: 375,
1865
1865
  S: this,
1866
1866
  C: (f, a) => f(...a)
1867
1867
  });
@@ -1871,7 +1871,7 @@ var Swarm = class {
1871
1871
  remoteId
1872
1872
  }, {
1873
1873
  F: __dxlog_file4,
1874
- L: 377,
1874
+ L: 378,
1875
1875
  S: this,
1876
1876
  C: (f, a) => f(...a)
1877
1877
  });
@@ -3255,6 +3255,7 @@ var SimplePeerTransportService = class {
3255
3255
  }
3256
3256
  };
3257
3257
  var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/simplepeer-transport-proxy.ts";
3258
+ var RPC_TIMEOUT = 1e4;
3258
3259
  var RESP_MIN_THRESHOLD = 500;
3259
3260
  var TIMEOUT_THRESHOLD = 10;
3260
3261
  var SimplePeerTransportProxy = class {
@@ -3270,12 +3271,14 @@ var SimplePeerTransportProxy = class {
3270
3271
  this._serviceStream = this._params.bridgeService.open({
3271
3272
  proxyId: this._proxyId,
3272
3273
  initiator: this._params.initiator
3274
+ }, {
3275
+ timeout: RPC_TIMEOUT
3273
3276
  });
3274
3277
  this._serviceStream.waitUntilReady().then(() => {
3275
3278
  this._serviceStream.subscribe(async (event) => {
3276
3279
  (0, import_log13.log)("SimplePeerTransportProxy: event", event, {
3277
3280
  F: __dxlog_file14,
3278
- L: 59,
3281
+ L: 63,
3279
3282
  S: this,
3280
3283
  C: (f, a) => f(...a)
3281
3284
  });
@@ -3294,12 +3297,12 @@ var SimplePeerTransportProxy = class {
3294
3297
  proxyId: this._proxyId,
3295
3298
  payload: chunk
3296
3299
  }, {
3297
- timeout: 1e4
3300
+ timeout: RPC_TIMEOUT
3298
3301
  }).then(() => {
3299
3302
  if (performance.now() - then > RESP_MIN_THRESHOLD) {
3300
3303
  (0, import_log13.log)("slow response, delaying callback", void 0, {
3301
3304
  F: __dxlog_file14,
3302
- L: 83,
3305
+ L: 87,
3303
3306
  S: this,
3304
3307
  C: (f, a) => f(...a)
3305
3308
  });
@@ -3311,11 +3314,11 @@ var SimplePeerTransportProxy = class {
3311
3314
  }, (err) => {
3312
3315
  if (err instanceof import_protocols8.TimeoutError || err.constructor.name === "TimeoutError") {
3313
3316
  if (this._timeoutCount++ > TIMEOUT_THRESHOLD) {
3314
- throw new import_protocols8.TimeoutError(`too many timeoutes (${this._timeoutCount} > ${TIMEOUT_THRESHOLD}`);
3317
+ throw new import_protocols8.TimeoutError(`too many timeouts (${this._timeoutCount} > ${TIMEOUT_THRESHOLD}`);
3315
3318
  } else {
3316
3319
  (0, import_log13.log)("timeout error, but still invoking callback", void 0, {
3317
3320
  F: __dxlog_file14,
3318
- L: 95,
3321
+ L: 99,
3319
3322
  S: this,
3320
3323
  C: (f, a) => f(...a)
3321
3324
  });
@@ -3324,7 +3327,7 @@ var SimplePeerTransportProxy = class {
3324
3327
  } else {
3325
3328
  import_log13.log.catch(err, void 0, {
3326
3329
  F: __dxlog_file14,
3327
- L: 99,
3330
+ L: 103,
3328
3331
  S: this,
3329
3332
  C: (f, a) => f(...a)
3330
3333
  });
@@ -3337,7 +3340,7 @@ var SimplePeerTransportProxy = class {
3337
3340
  err
3338
3341
  }, {
3339
3342
  F: __dxlog_file14,
3340
- L: 107,
3343
+ L: 111,
3341
3344
  S: this,
3342
3345
  C: (f, a) => f(...a)
3343
3346
  });
@@ -3345,7 +3348,7 @@ var SimplePeerTransportProxy = class {
3345
3348
  this._params.stream.pipe(proxyStream);
3346
3349
  }, (error) => import_log13.log.catch(error, void 0, {
3347
3350
  F: __dxlog_file14,
3348
- L: 112,
3351
+ L: 116,
3349
3352
  S: this,
3350
3353
  C: (f, a) => f(...a)
3351
3354
  }));
@@ -3375,16 +3378,22 @@ var SimplePeerTransportProxy = class {
3375
3378
  this._params.bridgeService.sendSignal({
3376
3379
  proxyId: this._proxyId,
3377
3380
  signal
3381
+ }, {
3382
+ timeout: RPC_TIMEOUT
3378
3383
  }).catch((err) => this.errors.raise(decodeError(err)));
3379
3384
  }
3380
3385
  async getDetails() {
3381
3386
  return (await this._params.bridgeService.getDetails({
3382
3387
  proxyId: this._proxyId
3388
+ }, {
3389
+ timeout: RPC_TIMEOUT
3383
3390
  })).details;
3384
3391
  }
3385
3392
  async getStats() {
3386
3393
  return (await this._params.bridgeService.getStats({
3387
3394
  proxyId: this._proxyId
3395
+ }, {
3396
+ timeout: RPC_TIMEOUT
3388
3397
  })).stats;
3389
3398
  }
3390
3399
  // TODO(burdon): Move open from constructor.
@@ -3397,11 +3406,13 @@ var SimplePeerTransportProxy = class {
3397
3406
  try {
3398
3407
  await this._params.bridgeService.close({
3399
3408
  proxyId: this._proxyId
3409
+ }, {
3410
+ timeout: RPC_TIMEOUT
3400
3411
  });
3401
3412
  } catch (err) {
3402
3413
  import_log13.log.catch(err, void 0, {
3403
3414
  F: __dxlog_file14,
3404
- L: 171,
3415
+ L: 179,
3405
3416
  S: this,
3406
3417
  C: (f, a) => f(...a)
3407
3418
  });
@@ -3437,7 +3448,7 @@ var SimplePeerTransportProxyFactory = class {
3437
3448
  createTransport(options) {
3438
3449
  (0, import_invariant12.invariant)(this._bridgeService, "SimplePeerTransportProxyFactory is not ready to open connections", {
3439
3450
  F: __dxlog_file14,
3440
- L: 208,
3451
+ L: 216,
3441
3452
  S: this,
3442
3453
  A: [
3443
3454
  "this._bridgeService",
@@ -4067,4 +4078,4 @@ var createTeleportProtocolFactory = (onConnection) => {
4067
4078
  createSimplePeerTransportFactory,
4068
4079
  createTeleportProtocolFactory
4069
4080
  });
4070
- //# sourceMappingURL=chunk-5D3NBEP2.cjs.map
4081
+ //# sourceMappingURL=chunk-HUPX2JGP.cjs.map