@glimt/record 0.0.62 → 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.js CHANGED
@@ -10464,13 +10464,18 @@ class MutationBuffer {
10464
10464
  __publicField(this, "stormBatches", []);
10465
10465
  __publicField(this, "stormInfo", null);
10466
10466
  __publicField(this, "stormSettings", {
10467
- batchSize: 150,
10467
+ batchSize: 50,
10468
10468
  //was 300
10469
10469
  timeout: 30,
10470
10470
  //was 50
10471
10471
  mutationLimit: 800
10472
10472
  //was 1500
10473
10473
  });
10474
+ __publicField(this, "rollingMutTracker", {
10475
+ accumlativeMuts: 0,
10476
+ ts: -1,
10477
+ interval: 10
10478
+ });
10474
10479
  __publicField(this, "handleStormMutations", (muts) => {
10475
10480
  const time = Date.now();
10476
10481
  if (this.stormInfo == null) {
@@ -10536,8 +10541,30 @@ class MutationBuffer {
10536
10541
  }
10537
10542
  });
10538
10543
  __publicField(this, "processInternalMutations", (muts, overrideStorm = false) => {
10539
- if (!overrideStorm && (this.stormInfo != null || muts.length >= this.stormSettings.batchSize)) {
10540
- this.handleStormMutations(muts);
10544
+ console.log("muts", muts.length);
10545
+ if (!overrideStorm) {
10546
+ if (this.stormInfo != null || muts.length >= this.stormSettings.batchSize) {
10547
+ this.handleStormMutations(muts);
10548
+ }
10549
+ if (this.stormInfo == null) {
10550
+ const now = Date.now();
10551
+ if (this.rollingMutTracker.ts === -1) {
10552
+ this.rollingMutTracker.accumlativeMuts = muts.length;
10553
+ } else {
10554
+ if (now - this.rollingMutTracker.ts <= this.rollingMutTracker.interval) {
10555
+ this.rollingMutTracker.accumlativeMuts += muts.length;
10556
+ if (this.rollingMutTracker.accumlativeMuts >= this.stormSettings.batchSize) {
10557
+ debugLog(`Mutation storm through rolling detected.`);
10558
+ this.handleStormMutations(muts);
10559
+ this.rollingMutTracker.accumlativeMuts = 0;
10560
+ this.rollingMutTracker.ts = -1;
10561
+ }
10562
+ } else {
10563
+ this.rollingMutTracker.accumlativeMuts = 0;
10564
+ }
10565
+ }
10566
+ this.rollingMutTracker.ts = now;
10567
+ }
10541
10568
  return;
10542
10569
  }
10543
10570
  for (const mut of muts) {