@rivetkit/workflow-engine 0.0.0-stack-fix-workflow-engine-clear-pruned-loop-history-via-batched-bounded-deletes-nrzuuryv.3dd5055 → 0.0.0-sync-sqlite.527e186

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.
@@ -1437,7 +1437,6 @@ function deserializeName(bytes) {
1437
1437
  // src/storage.ts
1438
1438
  var MAX_KV_BATCH_ENTRIES = 128;
1439
1439
  var MAX_KV_BATCH_PAYLOAD_BYTES = 976 * 1024;
1440
- var MAX_CONCURRENT_DELETES = 64;
1441
1440
  function createStorage() {
1442
1441
  return {
1443
1442
  nameRegistry: [],
@@ -1617,8 +1616,18 @@ async function flush(storage, driver, onHistoryUpdated, pendingDeletions) {
1617
1616
  }
1618
1617
  }
1619
1618
  if (pendingDeletions) {
1620
- const didChange = await runDeletes(driver, pendingDeletions);
1621
- if (didChange) {
1619
+ const deleteOps = [];
1620
+ for (const prefix of pendingDeletions.prefixes) {
1621
+ deleteOps.push(driver.deletePrefix(prefix));
1622
+ }
1623
+ for (const range of pendingDeletions.ranges) {
1624
+ deleteOps.push(driver.deleteRange(range.start, range.end));
1625
+ }
1626
+ for (const key of pendingDeletions.keys) {
1627
+ deleteOps.push(driver.delete(key));
1628
+ }
1629
+ if (deleteOps.length > 0) {
1630
+ await Promise.all(deleteOps);
1622
1631
  historyUpdated = true;
1623
1632
  }
1624
1633
  }
@@ -1660,36 +1669,10 @@ function splitBatchWrites(writes) {
1660
1669
  }
1661
1670
  return chunks;
1662
1671
  }
1663
- function splitBatchDeletes(keys) {
1664
- const chunks = [];
1665
- for (let i = 0; i < keys.length; i += MAX_KV_BATCH_ENTRIES) {
1666
- chunks.push(keys.slice(i, i + MAX_KV_BATCH_ENTRIES));
1667
- }
1668
- return chunks;
1669
- }
1670
- async function runDeletes(driver, deletions) {
1671
- const ops = [
1672
- ...deletions.prefixes.map((prefix) => () => driver.deletePrefix(prefix)),
1673
- ...deletions.ranges.map(
1674
- (range) => () => driver.deleteRange(range.start, range.end)
1675
- ),
1676
- ...splitBatchDeletes(deletions.keys).map(
1677
- (chunk) => () => driver.batchDelete(chunk)
1678
- )
1679
- ];
1680
- if (ops.length === 0) {
1681
- return false;
1682
- }
1683
- for (let i = 0; i < ops.length; i += MAX_CONCURRENT_DELETES) {
1684
- await Promise.all(
1685
- ops.slice(i, i + MAX_CONCURRENT_DELETES).map((op) => op())
1686
- );
1687
- }
1688
- return true;
1689
- }
1690
1672
  async function deleteEntriesWithPrefix(storage, driver, prefixLocation, onHistoryUpdated) {
1691
1673
  const deletions = collectDeletionsForPrefix(storage, prefixLocation);
1692
- await runDeletes(driver, deletions);
1674
+ await driver.deletePrefix(deletions.prefixes[0]);
1675
+ await Promise.all(deletions.keys.map((key) => driver.delete(key)));
1693
1676
  if (deletions.keys.length > 0 && onHistoryUpdated) {
1694
1677
  onHistoryUpdated();
1695
1678
  }
@@ -4338,4 +4321,4 @@ export {
4338
4321
  runWorkflow,
4339
4322
  replayWorkflowFromStep
4340
4323
  };
4341
- //# sourceMappingURL=chunk-UIZCJULV.js.map
4324
+ //# sourceMappingURL=chunk-DTS4S7RT.js.map