@dxos/echo-pipeline 0.3.8-main.8779a69 → 0.3.8-main.913b25a

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.
@@ -1580,7 +1580,7 @@ var DataPipeline = class DataPipeline2 {
1580
1580
  let messageCounter = 0;
1581
1581
  invariant8(this._pipeline, "Pipeline is not initialized.", {
1582
1582
  F: __dxlog_file9,
1583
- L: 222,
1583
+ L: 223,
1584
1584
  S: this,
1585
1585
  A: [
1586
1586
  "this._pipeline",
@@ -1596,7 +1596,7 @@ var DataPipeline = class DataPipeline2 {
1596
1596
  seq
1597
1597
  }, {
1598
1598
  F: __dxlog_file9,
1599
- L: 228,
1599
+ L: 229,
1600
1600
  S: this,
1601
1601
  C: (f, a) => f(...a)
1602
1602
  });
@@ -1608,7 +1608,7 @@ var DataPipeline = class DataPipeline2 {
1608
1608
  feedKey
1609
1609
  }, {
1610
1610
  F: __dxlog_file9,
1611
- L: 234,
1611
+ L: 235,
1612
1612
  S: this,
1613
1613
  C: (f, a) => f(...a)
1614
1614
  });
@@ -1631,7 +1631,7 @@ var DataPipeline = class DataPipeline2 {
1631
1631
  spaceKey: this._params.spaceKey.toHex()
1632
1632
  }, {
1633
1633
  F: __dxlog_file9,
1634
- L: 251,
1634
+ L: 252,
1635
1635
  S: this,
1636
1636
  C: (f, a) => f(...a)
1637
1637
  });
@@ -1640,22 +1640,22 @@ var DataPipeline = class DataPipeline2 {
1640
1640
  } catch (err) {
1641
1641
  log8.catch(err, void 0, {
1642
1642
  F: __dxlog_file9,
1643
- L: 261,
1643
+ L: 262,
1644
1644
  S: this,
1645
1645
  C: (f, a) => f(...a)
1646
1646
  });
1647
1647
  }
1648
1648
  span.end();
1649
- if (++messageCounter > 1e3) {
1649
+ if (++messageCounter > 100) {
1650
1650
  messageCounter = 0;
1651
- await sleep(1);
1651
+ await idle(1e3);
1652
1652
  }
1653
1653
  }
1654
1654
  }
1655
1655
  _createSnapshot() {
1656
1656
  invariant8(this.databaseHost, "Database backend is not initialized.", {
1657
1657
  F: __dxlog_file9,
1658
- L: 275,
1658
+ L: 276,
1659
1659
  S: this,
1660
1660
  A: [
1661
1661
  "this.databaseHost",
@@ -1684,7 +1684,7 @@ var DataPipeline = class DataPipeline2 {
1684
1684
  } catch (err) {
1685
1685
  log8.warn("Failed to cache properties", err, {
1686
1686
  F: __dxlog_file9,
1687
- L: 304,
1687
+ L: 305,
1688
1688
  S: this,
1689
1689
  C: (f, a) => f(...a)
1690
1690
  });
@@ -1713,14 +1713,14 @@ var DataPipeline = class DataPipeline2 {
1713
1713
  if (err instanceof CancelledError) {
1714
1714
  log8("Epoch processing cancelled.", void 0, {
1715
1715
  F: __dxlog_file9,
1716
- L: 340,
1716
+ L: 341,
1717
1717
  S: this,
1718
1718
  C: (f, a) => f(...a)
1719
1719
  });
1720
1720
  } else {
1721
1721
  log8.catch(err, void 0, {
1722
1722
  F: __dxlog_file9,
1723
- L: 342,
1723
+ L: 343,
1724
1724
  S: this,
1725
1725
  C: (f, a) => f(...a)
1726
1726
  });
@@ -1740,7 +1740,7 @@ var DataPipeline = class DataPipeline2 {
1740
1740
  async _processEpoch(ctx, epoch) {
1741
1741
  invariant8(this._isOpen, "Space is closed.", {
1742
1742
  F: __dxlog_file9,
1743
- L: 361,
1743
+ L: 362,
1744
1744
  S: this,
1745
1745
  A: [
1746
1746
  "this._isOpen",
@@ -1749,7 +1749,7 @@ var DataPipeline = class DataPipeline2 {
1749
1749
  });
1750
1750
  invariant8(this._pipeline, void 0, {
1751
1751
  F: __dxlog_file9,
1752
- L: 362,
1752
+ L: 363,
1753
1753
  S: this,
1754
1754
  A: [
1755
1755
  "this._pipeline",
@@ -1761,7 +1761,7 @@ var DataPipeline = class DataPipeline2 {
1761
1761
  epoch: omit(epoch, "proof")
1762
1762
  }, {
1763
1763
  F: __dxlog_file9,
1764
- L: 365,
1764
+ L: 366,
1765
1765
  S: this,
1766
1766
  C: (f, a) => f(...a)
1767
1767
  });
@@ -1771,7 +1771,7 @@ var DataPipeline = class DataPipeline2 {
1771
1771
  }
1772
1772
  log8("restarting pipeline from epoch", void 0, {
1773
1773
  F: __dxlog_file9,
1774
- L: 371,
1774
+ L: 372,
1775
1775
  S: this,
1776
1776
  C: (f, a) => f(...a)
1777
1777
  });
@@ -1782,7 +1782,7 @@ var DataPipeline = class DataPipeline2 {
1782
1782
  async waitUntilTimeframe(timeframe) {
1783
1783
  invariant8(this._pipeline, "Pipeline is not initialized.", {
1784
1784
  F: __dxlog_file9,
1785
- L: 378,
1785
+ L: 379,
1786
1786
  S: this,
1787
1787
  A: [
1788
1788
  "this._pipeline",
@@ -1794,7 +1794,7 @@ var DataPipeline = class DataPipeline2 {
1794
1794
  async createEpoch() {
1795
1795
  invariant8(this._pipeline, void 0, {
1796
1796
  F: __dxlog_file9,
1797
- L: 384,
1797
+ L: 385,
1798
1798
  S: this,
1799
1799
  A: [
1800
1800
  "this._pipeline",
@@ -1803,7 +1803,7 @@ var DataPipeline = class DataPipeline2 {
1803
1803
  });
1804
1804
  invariant8(this.currentEpoch, void 0, {
1805
1805
  F: __dxlog_file9,
1806
- L: 385,
1806
+ L: 386,
1807
1807
  S: this,
1808
1808
  A: [
1809
1809
  "this.currentEpoch",
@@ -1834,7 +1834,7 @@ var DataPipeline = class DataPipeline2 {
1834
1834
  } catch (err) {
1835
1835
  log8.catch(err, void 0, {
1836
1836
  F: __dxlog_file9,
1837
- L: 415,
1837
+ L: 416,
1838
1838
  S: this,
1839
1839
  C: (f, a) => f(...a)
1840
1840
  });
@@ -1864,6 +1864,31 @@ DataPipeline = _ts_decorate4([
1864
1864
  trackLeaks("open", "close"),
1865
1865
  trace.resource()
1866
1866
  ], DataPipeline);
1867
+ var idle = async (timeout) => {
1868
+ if (!("scheduler" in globalThis && typeof globalThis.scheduler.postTask === "function")) {
1869
+ await sleep(1);
1870
+ return;
1871
+ }
1872
+ await new Promise((resolve) => {
1873
+ const cleanup = () => {
1874
+ clearTimeout(timer);
1875
+ controller.abort();
1876
+ };
1877
+ const controller = new AbortController();
1878
+ void globalThis.scheduler.postTask(() => {
1879
+ cleanup();
1880
+ resolve();
1881
+ }, {
1882
+ priority: "background",
1883
+ signal: controller.signal
1884
+ }).catch(() => {
1885
+ });
1886
+ const timer = setTimeout(() => {
1887
+ cleanup();
1888
+ resolve();
1889
+ }, timeout);
1890
+ });
1891
+ };
1867
1892
 
1868
1893
  // packages/core/echo/echo-pipeline/src/space/space.ts
1869
1894
  import { Event as Event5, synchronized as synchronized4, trackLeaks as trackLeaks3, Lock } from "@dxos/async";
@@ -2712,4 +2737,4 @@ export {
2712
2737
  SpaceProtocolSession,
2713
2738
  SpaceManager
2714
2739
  };
2715
- //# sourceMappingURL=chunk-KD6OVLI6.mjs.map
2740
+ //# sourceMappingURL=chunk-EIHG3NK5.mjs.map