@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.
@@ -9686,7 +9686,10 @@ const _StormSnapshotManager = class _StormSnapshotManager2 {
9686
9686
  //before we actually take a full snapshot.
9687
9687
  //also, we want a low debounceTime, bc if theres multiple, distinctive mutation storms,
9688
9688
  //in a somewhat quick succession, we want to record activity between them
9689
- //not just one full snapshot after all the storms
9689
+ //not just one full snapshot after all the storms:
9690
+ //[mutation storm] [full snapshot] [mutation storm] [full snapshot]
9691
+ //NOT
9692
+ //[mutation storm] [timeout] [mutation storm] [full snapshot] (in this case, we probably miss all events which fired during the timeout)
9690
9693
  requestFullSnapshot() {
9691
9694
  if (this.debounceTimeout) {
9692
9695
  clearTimeout(this.debounceTimeout);
@@ -9837,11 +9840,14 @@ class MutationBuffer {
9837
9840
  __publicField(this, "unattachedDoc");
9838
9841
  __publicField(this, "bufId", makeid());
9839
9842
  __publicField(this, "stormBatches", []);
9840
- __publicField(this, "stormInfo");
9843
+ __publicField(this, "stormInfo", null);
9841
9844
  __publicField(this, "stormSettings", {
9842
- batchSize: 300,
9843
- timeout: 50,
9844
- mutationLimit: 1500
9845
+ batchSize: 150,
9846
+ //was 300
9847
+ timeout: 30,
9848
+ //was 50
9849
+ mutationLimit: 800
9850
+ //was 1500
9845
9851
  });
9846
9852
  __publicField(this, "handleStormMutations", (muts) => {
9847
9853
  const time = Date.now();
@@ -9859,12 +9865,6 @@ class MutationBuffer {
9859
9865
  };
9860
9866
  }
9861
9867
  this.stormInfo.totalMutations += muts.length;
9862
- console.log(
9863
- "current storm mutations",
9864
- this.stormInfo.totalMutations,
9865
- "buffer id:",
9866
- this.bufId
9867
- );
9868
9868
  if (this.stormInfo.totalMutations >= this.stormSettings.mutationLimit) {
9869
9869
  this.stormInfo.stormExceededLimit = true;
9870
9870
  this.stormBatches = [];
@@ -9874,9 +9874,14 @@ class MutationBuffer {
9874
9874
  mutations: muts
9875
9875
  });
9876
9876
  }
9877
+ clearTimeout(this.stormInfo.timeout);
9877
9878
  if (muts.length < this.stormSettings.batchSize) {
9878
- clearTimeout(this.stormInfo.timeout);
9879
9879
  this.handleStormFinish();
9880
+ } else {
9881
+ this.stormInfo.timeout = setTimeout(
9882
+ this.handleStormFinish,
9883
+ this.stormSettings.timeout
9884
+ );
9880
9885
  }
9881
9886
  });
9882
9887
  __publicField(this, "handleStormFinish", () => {
@@ -9913,20 +9918,9 @@ class MutationBuffer {
9913
9918
  this.handleStormMutations(muts);
9914
9919
  return;
9915
9920
  }
9916
- const start = performance.now();
9917
9921
  for (const mut of muts) {
9918
9922
  this.processMutation(mut);
9919
9923
  }
9920
- console.log(
9921
- muts.length,
9922
- "mutations processed in",
9923
- performance.now() - start,
9924
- "ms",
9925
- "overrideStorm",
9926
- overrideStorm,
9927
- "buffer id:",
9928
- this.bufId
9929
- );
9930
9924
  this.emit();
9931
9925
  });
9932
9926
  __publicField(this, "processMutations", (mutations) => {