@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.
package/dist/record.cjs CHANGED
@@ -10473,6 +10473,11 @@ class MutationBuffer {
10473
10473
  mutationLimit: 800
10474
10474
  //was 1500
10475
10475
  });
10476
+ __publicField(this, "rollingMutTracker", {
10477
+ accumlativeMuts: 0,
10478
+ ts: -1,
10479
+ interval: 10
10480
+ });
10476
10481
  __publicField(this, "handleStormMutations", (muts) => {
10477
10482
  const time = Date.now();
10478
10483
  if (this.stormInfo == null) {
@@ -10539,8 +10544,29 @@ class MutationBuffer {
10539
10544
  });
10540
10545
  __publicField(this, "processInternalMutations", (muts, overrideStorm = false) => {
10541
10546
  console.log("muts", muts.length);
10542
- if (!overrideStorm && (this.stormInfo != null || muts.length >= this.stormSettings.batchSize)) {
10543
- this.handleStormMutations(muts);
10547
+ if (!overrideStorm) {
10548
+ if (this.stormInfo != null || muts.length >= this.stormSettings.batchSize) {
10549
+ this.handleStormMutations(muts);
10550
+ }
10551
+ if (this.stormInfo == null) {
10552
+ const now = Date.now();
10553
+ if (this.rollingMutTracker.ts === -1) {
10554
+ this.rollingMutTracker.accumlativeMuts = muts.length;
10555
+ } else {
10556
+ if (now - this.rollingMutTracker.ts <= this.rollingMutTracker.interval) {
10557
+ this.rollingMutTracker.accumlativeMuts += muts.length;
10558
+ if (this.rollingMutTracker.accumlativeMuts >= this.stormSettings.batchSize) {
10559
+ debugLog(`Mutation storm through rolling detected.`);
10560
+ this.handleStormMutations(muts);
10561
+ this.rollingMutTracker.accumlativeMuts = 0;
10562
+ this.rollingMutTracker.ts = -1;
10563
+ }
10564
+ } else {
10565
+ this.rollingMutTracker.accumlativeMuts = 0;
10566
+ }
10567
+ }
10568
+ this.rollingMutTracker.ts = now;
10569
+ }
10544
10570
  return;
10545
10571
  }
10546
10572
  for (const mut of muts) {