@glimt/record 0.0.34 → 0.0.35

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.
package/dist/record.cjs CHANGED
@@ -9644,7 +9644,10 @@ const _StormSnapshotManager = class _StormSnapshotManager2 {
9644
9644
  //before we actually take a full snapshot.
9645
9645
  //also, we want a low debounceTime, bc if theres multiple, distinctive mutation storms,
9646
9646
  //in a somewhat quick succession, we want to record activity between them
9647
- //not just one full snapshot after all the storms
9647
+ //not just one full snapshot after all the storms:
9648
+ //[mutation storm] [full snapshot] [mutation storm] [full snapshot]
9649
+ //NOT
9650
+ //[mutation storm] [timeout] [mutation storm] [full snapshot] (in this case, we probably miss all events which fired during the timeout)
9648
9651
  requestFullSnapshot() {
9649
9652
  if (this.debounceTimeout) {
9650
9653
  clearTimeout(this.debounceTimeout);
@@ -9795,11 +9798,14 @@ class MutationBuffer {
9795
9798
  __publicField(this, "unattachedDoc");
9796
9799
  __publicField(this, "bufId", makeid());
9797
9800
  __publicField(this, "stormBatches", []);
9798
- __publicField(this, "stormInfo");
9801
+ __publicField(this, "stormInfo", null);
9799
9802
  __publicField(this, "stormSettings", {
9800
- batchSize: 300,
9801
- timeout: 50,
9802
- mutationLimit: 1500
9803
+ batchSize: 150,
9804
+ //was 300
9805
+ timeout: 30,
9806
+ //was 50
9807
+ mutationLimit: 800
9808
+ //was 1500
9803
9809
  });
9804
9810
  __publicField(this, "handleStormMutations", (muts) => {
9805
9811
  const time = Date.now();
@@ -9817,12 +9823,6 @@ class MutationBuffer {
9817
9823
  };
9818
9824
  }
9819
9825
  this.stormInfo.totalMutations += muts.length;
9820
- console.log(
9821
- "current storm mutations",
9822
- this.stormInfo.totalMutations,
9823
- "buffer id:",
9824
- this.bufId
9825
- );
9826
9826
  if (this.stormInfo.totalMutations >= this.stormSettings.mutationLimit) {
9827
9827
  this.stormInfo.stormExceededLimit = true;
9828
9828
  this.stormBatches = [];
@@ -9832,9 +9832,14 @@ class MutationBuffer {
9832
9832
  mutations: muts
9833
9833
  });
9834
9834
  }
9835
+ clearTimeout(this.stormInfo.timeout);
9835
9836
  if (muts.length < this.stormSettings.batchSize) {
9836
- clearTimeout(this.stormInfo.timeout);
9837
9837
  this.handleStormFinish();
9838
+ } else {
9839
+ this.stormInfo.timeout = setTimeout(
9840
+ this.handleStormFinish,
9841
+ this.stormSettings.timeout
9842
+ );
9838
9843
  }
9839
9844
  });
9840
9845
  __publicField(this, "handleStormFinish", () => {
@@ -9871,20 +9876,9 @@ class MutationBuffer {
9871
9876
  this.handleStormMutations(muts);
9872
9877
  return;
9873
9878
  }
9874
- const start = performance.now();
9875
9879
  for (const mut of muts) {
9876
9880
  this.processMutation(mut);
9877
9881
  }
9878
- console.log(
9879
- muts.length,
9880
- "mutations processed in",
9881
- performance.now() - start,
9882
- "ms",
9883
- "overrideStorm",
9884
- overrideStorm,
9885
- "buffer id:",
9886
- this.bufId
9887
- );
9888
9882
  this.emit();
9889
9883
  });
9890
9884
  __publicField(this, "processMutations", (mutations) => {