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