@dxos/echo-pipeline 0.1.56-main.ed2f871 → 0.1.56-main.f2c137d

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.
@@ -716,7 +716,7 @@ import { invariant as invariant6 } from "@dxos/invariant";
716
716
  import { PublicKey as PublicKey3 } from "@dxos/keys";
717
717
  import { log as log6 } from "@dxos/log";
718
718
  import { Timeframe as Timeframe2 } from "@dxos/timeframe";
719
- import { ComplexMap as ComplexMap3 } from "@dxos/util";
719
+ import { ComplexMap as ComplexMap3, getPrototypeSpecificInstanceId } from "@dxos/util";
720
720
 
721
721
  // packages/core/echo/echo-pipeline/src/pipeline/message-selector.ts
722
722
  import { invariant as invariant5 } from "@dxos/invariant";
@@ -869,7 +869,7 @@ var Pipeline = class {
869
869
  this._pauseTrigger = new Trigger().wake();
870
870
  this._isStopping = false;
871
871
  this._isStarted = false;
872
- this._isOpen = false;
872
+ this._isBeingConsumed = false;
873
873
  this._isPaused = false;
874
874
  }
875
875
  get state() {
@@ -900,12 +900,14 @@ var Pipeline = class {
900
900
  if (this._feedSetIterator) {
901
901
  await this._feedSetIterator.addFeed(feed);
902
902
  }
903
- this._setFeedDownloadState(feed);
903
+ if (this._isStarted && !this._isPaused) {
904
+ this._setFeedDownloadState(feed);
905
+ }
904
906
  }
905
907
  setWriteFeed(feed) {
906
908
  invariant6(!this._writer, "Writer already set.", {
907
909
  F: __dxlog_file7,
908
- L: 253,
910
+ L: 257,
909
911
  S: this,
910
912
  A: [
911
913
  "!this._writer",
@@ -914,7 +916,7 @@ var Pipeline = class {
914
916
  });
915
917
  invariant6(feed.properties.writable, "Feed must be writable.", {
916
918
  F: __dxlog_file7,
917
- L: 254,
919
+ L: 258,
918
920
  S: this,
919
921
  A: [
920
922
  "feed.properties.writable",
@@ -929,7 +931,7 @@ var Pipeline = class {
929
931
  async start() {
930
932
  invariant6(!this._isStarted, "Pipeline is already started.", {
931
933
  F: __dxlog_file7,
932
- L: 267,
934
+ L: 271,
933
935
  S: this,
934
936
  A: [
935
937
  "!this._isStarted",
@@ -938,7 +940,7 @@ var Pipeline = class {
938
940
  });
939
941
  log6("starting...", void 0, {
940
942
  F: __dxlog_file7,
941
- L: 268,
943
+ L: 272,
942
944
  S: this,
943
945
  C: (f, a) => f(...a)
944
946
  });
@@ -947,15 +949,20 @@ var Pipeline = class {
947
949
  this._isStarted = true;
948
950
  log6("started", void 0, {
949
951
  F: __dxlog_file7,
950
- L: 272,
952
+ L: 276,
951
953
  S: this,
952
954
  C: (f, a) => f(...a)
953
955
  });
956
+ if (!this._isPaused) {
957
+ for (const feed of this._feeds.values()) {
958
+ this._setFeedDownloadState(feed);
959
+ }
960
+ }
954
961
  }
955
962
  async stop() {
956
963
  log6("stopping...", void 0, {
957
964
  F: __dxlog_file7,
958
- L: 277,
965
+ L: 287,
959
966
  S: this,
960
967
  C: (f, a) => f(...a)
961
968
  });
@@ -968,7 +975,7 @@ var Pipeline = class {
968
975
  this._isStarted = false;
969
976
  log6("stopped", void 0, {
970
977
  F: __dxlog_file7,
971
- L: 285,
978
+ L: 295,
972
979
  S: this,
973
980
  C: (f, a) => f(...a)
974
981
  });
@@ -980,7 +987,7 @@ var Pipeline = class {
980
987
  async setCursor(timeframe) {
981
988
  invariant6(!this._isStarted || this._isPaused, "Invalid state.", {
982
989
  F: __dxlog_file7,
983
- L: 294,
990
+ L: 304,
984
991
  S: this,
985
992
  A: [
986
993
  "!this._isStarted || this._isPaused",
@@ -989,9 +996,6 @@ var Pipeline = class {
989
996
  });
990
997
  this._state._startTimeframe = timeframe;
991
998
  this._timeframeClock.setTimeframe(timeframe);
992
- for (const feed of this._feeds.values()) {
993
- this._setFeedDownloadState(feed);
994
- }
995
999
  if (this._feedSetIterator) {
996
1000
  await this._feedSetIterator.close();
997
1001
  await this._initIterator();
@@ -1002,15 +1006,6 @@ var Pipeline = class {
1002
1006
  * Calling pause while processing will cause a deadlock.
1003
1007
  */
1004
1008
  async pause() {
1005
- invariant6(this._isStarted, "Pipeline is not open.", {
1006
- F: __dxlog_file7,
1007
- L: 316,
1008
- S: this,
1009
- A: [
1010
- "this._isStarted",
1011
- "'Pipeline is not open.'"
1012
- ]
1013
- });
1014
1009
  if (this._isPaused) {
1015
1010
  return;
1016
1011
  }
@@ -1019,18 +1014,9 @@ var Pipeline = class {
1019
1014
  this._isPaused = true;
1020
1015
  }
1021
1016
  async unpause() {
1022
- invariant6(this._isStarted, "Pipeline is not open.", {
1023
- F: __dxlog_file7,
1024
- L: 328,
1025
- S: this,
1026
- A: [
1027
- "this._isStarted",
1028
- "'Pipeline is not open.'"
1029
- ]
1030
- });
1031
1017
  invariant6(this._isPaused, "Pipeline is not paused.", {
1032
1018
  F: __dxlog_file7,
1033
- L: 329,
1019
+ L: 334,
1034
1020
  S: this,
1035
1021
  A: [
1036
1022
  "this._isPaused",
@@ -1039,25 +1025,28 @@ var Pipeline = class {
1039
1025
  });
1040
1026
  this._pauseTrigger.wake();
1041
1027
  this._isPaused = false;
1028
+ for (const feed of this._feeds.values()) {
1029
+ this._setFeedDownloadState(feed);
1030
+ }
1042
1031
  }
1043
1032
  /**
1044
1033
  * Starts to iterate over the ordered messages from the added feeds.
1045
1034
  * Updates the timeframe clock after the message has bee processed.
1046
1035
  */
1047
1036
  async *consume() {
1048
- invariant6(!this._isOpen, "Pipeline is already being consumed.", {
1037
+ invariant6(!this._isBeingConsumed, "Pipeline is already being consumed.", {
1049
1038
  F: __dxlog_file7,
1050
- L: 340,
1039
+ L: 349,
1051
1040
  S: this,
1052
1041
  A: [
1053
- "!this._isOpen",
1042
+ "!this._isBeingConsumed",
1054
1043
  "'Pipeline is already being consumed.'"
1055
1044
  ]
1056
1045
  });
1057
- this._isOpen = true;
1046
+ this._isBeingConsumed = true;
1058
1047
  invariant6(this._feedSetIterator, "Iterator not initialized.", {
1059
1048
  F: __dxlog_file7,
1060
- L: 343,
1049
+ L: 352,
1061
1050
  S: this,
1062
1051
  A: [
1063
1052
  "this._feedSetIterator",
@@ -1071,7 +1060,7 @@ var Pipeline = class {
1071
1060
  if (lastFeedSetIterator !== this._feedSetIterator) {
1072
1061
  invariant6(this._feedSetIterator, "Iterator not initialized.", {
1073
1062
  F: __dxlog_file7,
1074
- L: 352,
1063
+ L: 361,
1075
1064
  S: this,
1076
1065
  A: [
1077
1066
  "this._feedSetIterator",
@@ -1091,15 +1080,31 @@ var Pipeline = class {
1091
1080
  this._timeframeClock.updateTimeframe();
1092
1081
  }
1093
1082
  }
1094
- this._isOpen = false;
1083
+ this._isBeingConsumed = false;
1095
1084
  }
1096
1085
  _setFeedDownloadState(feed) {
1097
1086
  const timeframe = this._state._startTimeframe;
1098
- const seq = timeframe.get(feed.key) ?? 0;
1087
+ const seq = timeframe.get(feed.key) ?? -1;
1088
+ log6.info("setFeedDownloadState", {
1089
+ feed: feed.key,
1090
+ feedInstance: getPrototypeSpecificInstanceId(feed),
1091
+ seq,
1092
+ isBeingConsumed: this._isBeingConsumed,
1093
+ isStarted: this._isStarted,
1094
+ isPaused: this._isPaused
1095
+ }, {
1096
+ F: __dxlog_file7,
1097
+ L: 386,
1098
+ S: this,
1099
+ C: (f, a) => f(...a)
1100
+ });
1101
+ if (!this._isStarted || this._isPaused) {
1102
+ console.log(new Error().stack);
1103
+ }
1099
1104
  feed.undownload({
1100
1105
  callback: () => log6("undownload", void 0, {
1101
1106
  F: __dxlog_file7,
1102
- L: 377,
1107
+ L: 398,
1103
1108
  S: this,
1104
1109
  C: (f, a) => f(...a)
1105
1110
  })
@@ -1112,7 +1117,7 @@ var Pipeline = class {
1112
1117
  err
1113
1118
  }, {
1114
1119
  F: __dxlog_file7,
1115
- L: 379,
1120
+ L: 400,
1116
1121
  S: this,
1117
1122
  C: (f, a) => f(...a)
1118
1123
  });
@@ -1126,7 +1131,7 @@ var Pipeline = class {
1126
1131
  this._feedSetIterator.stalled.on((iterator) => {
1127
1132
  log6.warn(`Stalled after ${iterator.options.stallTimeout}ms with ${iterator.size} feeds.`, void 0, {
1128
1133
  F: __dxlog_file7,
1129
- L: 390,
1134
+ L: 411,
1130
1135
  S: this,
1131
1136
  C: (f, a) => f(...a)
1132
1137
  });
@@ -1323,8 +1328,8 @@ var DataPipeline = class DataPipeline2 {
1323
1328
  }
1324
1329
  this._pipeline = new Pipeline();
1325
1330
  await this._params.onPipelineCreated(this._pipeline);
1326
- await this._pipeline.start();
1327
1331
  await this._pipeline.pause();
1332
+ await this._pipeline.start();
1328
1333
  if (this._targetTimeframe) {
1329
1334
  this._pipeline.state.setTargetTimeframe(this._targetTimeframe);
1330
1335
  }
@@ -1332,7 +1337,7 @@ var DataPipeline = class DataPipeline2 {
1332
1337
  write: (data, options) => {
1333
1338
  invariant8(this._pipeline, "Pipeline is not initialized.", {
1334
1339
  F: __dxlog_file9,
1335
- L: 145,
1340
+ L: 146,
1336
1341
  S: this,
1337
1342
  A: [
1338
1343
  "this._pipeline",
@@ -1341,7 +1346,7 @@ var DataPipeline = class DataPipeline2 {
1341
1346
  });
1342
1347
  invariant8(this.currentEpoch, "Epoch is not initialized.", {
1343
1348
  F: __dxlog_file9,
1344
- L: 146,
1349
+ L: 147,
1345
1350
  S: this,
1346
1351
  A: [
1347
1352
  "this.currentEpoch",
@@ -1367,7 +1372,7 @@ var DataPipeline = class DataPipeline2 {
1367
1372
  }
1368
1373
  log8("close", void 0, {
1369
1374
  F: __dxlog_file9,
1370
- L: 170,
1375
+ L: 171,
1371
1376
  S: this,
1372
1377
  C: (f, a) => f(...a)
1373
1378
  });
@@ -1382,7 +1387,7 @@ var DataPipeline = class DataPipeline2 {
1382
1387
  } catch (err) {
1383
1388
  log8.catch(err, void 0, {
1384
1389
  F: __dxlog_file9,
1385
- L: 183,
1390
+ L: 184,
1386
1391
  S: this,
1387
1392
  C: (f, a) => f(...a)
1388
1393
  });
@@ -1406,7 +1411,7 @@ var DataPipeline = class DataPipeline2 {
1406
1411
  }
1407
1412
  invariant8(this._pipeline, "Pipeline is not initialized.", {
1408
1413
  F: __dxlog_file9,
1409
- L: 206,
1414
+ L: 207,
1410
1415
  S: this,
1411
1416
  A: [
1412
1417
  "this._pipeline",
@@ -1420,7 +1425,7 @@ var DataPipeline = class DataPipeline2 {
1420
1425
  seq
1421
1426
  }, {
1422
1427
  F: __dxlog_file9,
1423
- L: 209,
1428
+ L: 210,
1424
1429
  S: this,
1425
1430
  C: (f, a) => f(...a)
1426
1431
  });
@@ -1432,7 +1437,7 @@ var DataPipeline = class DataPipeline2 {
1432
1437
  feedKey
1433
1438
  }, {
1434
1439
  F: __dxlog_file9,
1435
- L: 215,
1440
+ L: 216,
1436
1441
  S: this,
1437
1442
  C: (f, a) => f(...a)
1438
1443
  });
@@ -1455,7 +1460,7 @@ var DataPipeline = class DataPipeline2 {
1455
1460
  spaceKey: this._params.spaceKey.toHex()
1456
1461
  }, {
1457
1462
  F: __dxlog_file9,
1458
- L: 232,
1463
+ L: 233,
1459
1464
  S: this,
1460
1465
  C: (f, a) => f(...a)
1461
1466
  });
@@ -1464,7 +1469,7 @@ var DataPipeline = class DataPipeline2 {
1464
1469
  } catch (err) {
1465
1470
  log8.catch(err, void 0, {
1466
1471
  F: __dxlog_file9,
1467
- L: 242,
1472
+ L: 243,
1468
1473
  S: this,
1469
1474
  C: (f, a) => f(...a)
1470
1475
  });
@@ -1474,7 +1479,7 @@ var DataPipeline = class DataPipeline2 {
1474
1479
  _createSnapshot() {
1475
1480
  invariant8(this.databaseHost, "Database backend is not initialized.", {
1476
1481
  F: __dxlog_file9,
1477
- L: 248,
1482
+ L: 249,
1478
1483
  S: this,
1479
1484
  A: [
1480
1485
  "this.databaseHost",
@@ -1503,7 +1508,7 @@ var DataPipeline = class DataPipeline2 {
1503
1508
  } catch (err) {
1504
1509
  log8.warn("Failed to cache properties", err, {
1505
1510
  F: __dxlog_file9,
1506
- L: 277,
1511
+ L: 278,
1507
1512
  S: this,
1508
1513
  C: (f, a) => f(...a)
1509
1514
  });
@@ -1529,14 +1534,14 @@ var DataPipeline = class DataPipeline2 {
1529
1534
  if (err instanceof CancelledError) {
1530
1535
  log8("Epoch processing cancelled.", void 0, {
1531
1536
  F: __dxlog_file9,
1532
- L: 309,
1537
+ L: 310,
1533
1538
  S: this,
1534
1539
  C: (f, a) => f(...a)
1535
1540
  });
1536
1541
  } else {
1537
1542
  log8.catch(err, void 0, {
1538
1543
  F: __dxlog_file9,
1539
- L: 311,
1544
+ L: 312,
1540
1545
  S: this,
1541
1546
  C: (f, a) => f(...a)
1542
1547
  });
@@ -1552,7 +1557,7 @@ var DataPipeline = class DataPipeline2 {
1552
1557
  epoch
1553
1558
  }, {
1554
1559
  F: __dxlog_file9,
1555
- L: 321,
1560
+ L: 322,
1556
1561
  S: this,
1557
1562
  C: (f, a) => f(...a)
1558
1563
  });
@@ -1564,7 +1569,7 @@ var DataPipeline = class DataPipeline2 {
1564
1569
  async _processEpoch(ctx, epoch) {
1565
1570
  invariant8(this._isOpen, "Space is closed.", {
1566
1571
  F: __dxlog_file9,
1567
- L: 331,
1572
+ L: 332,
1568
1573
  S: this,
1569
1574
  A: [
1570
1575
  "this._isOpen",
@@ -1573,7 +1578,7 @@ var DataPipeline = class DataPipeline2 {
1573
1578
  });
1574
1579
  invariant8(this._pipeline, void 0, {
1575
1580
  F: __dxlog_file9,
1576
- L: 332,
1581
+ L: 333,
1577
1582
  S: this,
1578
1583
  A: [
1579
1584
  "this._pipeline",
@@ -1585,7 +1590,7 @@ var DataPipeline = class DataPipeline2 {
1585
1590
  epoch
1586
1591
  }, {
1587
1592
  F: __dxlog_file9,
1588
- L: 335,
1593
+ L: 336,
1589
1594
  S: this,
1590
1595
  C: (f, a) => f(...a)
1591
1596
  });
@@ -1595,7 +1600,7 @@ var DataPipeline = class DataPipeline2 {
1595
1600
  }
1596
1601
  log8("restarting pipeline for epoch", void 0, {
1597
1602
  F: __dxlog_file9,
1598
- L: 343,
1603
+ L: 344,
1599
1604
  S: this,
1600
1605
  C: (f, a) => f(...a)
1601
1606
  });
@@ -1606,7 +1611,7 @@ var DataPipeline = class DataPipeline2 {
1606
1611
  async waitUntilTimeframe(timeframe) {
1607
1612
  invariant8(this._pipeline, "Pipeline is not initialized.", {
1608
1613
  F: __dxlog_file9,
1609
- L: 351,
1614
+ L: 352,
1610
1615
  S: this,
1611
1616
  A: [
1612
1617
  "this._pipeline",
@@ -1618,7 +1623,7 @@ var DataPipeline = class DataPipeline2 {
1618
1623
  async createEpoch() {
1619
1624
  invariant8(this._pipeline, void 0, {
1620
1625
  F: __dxlog_file9,
1621
- L: 357,
1626
+ L: 358,
1622
1627
  S: this,
1623
1628
  A: [
1624
1629
  "this._pipeline",
@@ -1627,7 +1632,7 @@ var DataPipeline = class DataPipeline2 {
1627
1632
  });
1628
1633
  invariant8(this.currentEpoch, void 0, {
1629
1634
  F: __dxlog_file9,
1630
- L: 358,
1635
+ L: 359,
1631
1636
  S: this,
1632
1637
  A: [
1633
1638
  "this.currentEpoch",
@@ -2388,4 +2393,4 @@ export {
2388
2393
  SpaceProtocolSession,
2389
2394
  SpaceManager
2390
2395
  };
2391
- //# sourceMappingURL=chunk-3OTHGQEY.mjs.map
2396
+ //# sourceMappingURL=chunk-M66GL5HD.mjs.map