@glimt/record 0.0.63 → 0.0.64

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.
@@ -10515,6 +10515,11 @@ class MutationBuffer {
10515
10515
  mutationLimit: 800
10516
10516
  //was 1500
10517
10517
  });
10518
+ __publicField(this, "rollingMutTracker", {
10519
+ accumlativeMuts: 0,
10520
+ ts: -1,
10521
+ interval: 10
10522
+ });
10518
10523
  __publicField(this, "handleStormMutations", (muts) => {
10519
10524
  const time = Date.now();
10520
10525
  if (this.stormInfo == null) {
@@ -10581,8 +10586,29 @@ class MutationBuffer {
10581
10586
  });
10582
10587
  __publicField(this, "processInternalMutations", (muts, overrideStorm = false) => {
10583
10588
  console.log("muts", muts.length);
10584
- if (!overrideStorm && (this.stormInfo != null || muts.length >= this.stormSettings.batchSize)) {
10585
- this.handleStormMutations(muts);
10589
+ if (!overrideStorm) {
10590
+ if (this.stormInfo != null || muts.length >= this.stormSettings.batchSize) {
10591
+ this.handleStormMutations(muts);
10592
+ }
10593
+ if (this.stormInfo == null) {
10594
+ const now = Date.now();
10595
+ if (this.rollingMutTracker.ts === -1) {
10596
+ this.rollingMutTracker.accumlativeMuts = muts.length;
10597
+ } else {
10598
+ if (now - this.rollingMutTracker.ts <= this.rollingMutTracker.interval) {
10599
+ this.rollingMutTracker.accumlativeMuts += muts.length;
10600
+ if (this.rollingMutTracker.accumlativeMuts >= this.stormSettings.batchSize) {
10601
+ debugLog(`Mutation storm through rolling detected.`);
10602
+ this.handleStormMutations(muts);
10603
+ this.rollingMutTracker.accumlativeMuts = 0;
10604
+ this.rollingMutTracker.ts = -1;
10605
+ }
10606
+ } else {
10607
+ this.rollingMutTracker.accumlativeMuts = 0;
10608
+ }
10609
+ }
10610
+ this.rollingMutTracker.ts = now;
10611
+ }
10586
10612
  return;
10587
10613
  }
10588
10614
  for (const mut of muts) {