@glimt/record 0.0.69 → 0.0.71
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 +80 -13
- package/dist/record.cjs.map +1 -1
- package/dist/record.js +80 -13
- package/dist/record.js.map +1 -1
- package/dist/record.umd.cjs +80 -13
- package/dist/record.umd.cjs.map +2 -2
- package/dist/record.umd.min.cjs +27 -27
- package/dist/record.umd.min.cjs.map +2 -2
- package/package.json +1 -1
package/dist/record.cjs
CHANGED
|
@@ -10330,9 +10330,13 @@ const stormSnapshotManager = new StormSnapshotManager();
|
|
|
10330
10330
|
const _MutationRateLimiter = class _MutationRateLimiter2 {
|
|
10331
10331
|
constructor() {
|
|
10332
10332
|
__publicField(this, "mutTracker");
|
|
10333
|
+
__publicField(this, "exitMutTracker");
|
|
10333
10334
|
__publicField(this, "interval", 50);
|
|
10334
|
-
__publicField(this, "
|
|
10335
|
+
__publicField(this, "exitInterval", 100);
|
|
10336
|
+
__publicField(this, "mutThreshold", 100);
|
|
10335
10337
|
__publicField(this, "inGlobalStorm", false);
|
|
10338
|
+
__publicField(this, "currentStormStartedAt", -1);
|
|
10339
|
+
__publicField(this, "stormTimeLimit", 5e3);
|
|
10336
10340
|
if (_MutationRateLimiter2.instance) {
|
|
10337
10341
|
return _MutationRateLimiter2.instance;
|
|
10338
10342
|
}
|
|
@@ -10340,24 +10344,78 @@ const _MutationRateLimiter = class _MutationRateLimiter2 {
|
|
|
10340
10344
|
debugLog(`MutationRateLimiter, init`);
|
|
10341
10345
|
this.reset();
|
|
10342
10346
|
}
|
|
10343
|
-
|
|
10347
|
+
resetTracker() {
|
|
10344
10348
|
this.mutTracker = {
|
|
10345
10349
|
muts: 0,
|
|
10346
10350
|
ts: -1
|
|
10347
10351
|
};
|
|
10348
10352
|
}
|
|
10353
|
+
resetExitTracker() {
|
|
10354
|
+
this.exitMutTracker = {
|
|
10355
|
+
muts: 0,
|
|
10356
|
+
requested: -1
|
|
10357
|
+
};
|
|
10358
|
+
}
|
|
10359
|
+
reset() {
|
|
10360
|
+
this.resetTracker();
|
|
10361
|
+
this.resetExitTracker();
|
|
10362
|
+
this.currentStormStartedAt = -1;
|
|
10363
|
+
}
|
|
10364
|
+
stormStopped() {
|
|
10365
|
+
this.inGlobalStorm = false;
|
|
10366
|
+
this.reset();
|
|
10367
|
+
}
|
|
10368
|
+
handleStormExit(muts) {
|
|
10369
|
+
const now = Date.now();
|
|
10370
|
+
if (this.exitMutTracker.requested === -1) {
|
|
10371
|
+
this.exitMutTracker = {
|
|
10372
|
+
requested: now,
|
|
10373
|
+
muts
|
|
10374
|
+
};
|
|
10375
|
+
} else {
|
|
10376
|
+
this.exitMutTracker.muts += muts;
|
|
10377
|
+
if (now - this.exitMutTracker.requested > this.exitInterval) {
|
|
10378
|
+
if (this.exitMutTracker.muts >= this.mutThreshold) {
|
|
10379
|
+
debugLog(
|
|
10380
|
+
`MutationRateLimiter, exit cooldown failed, continuing with storm`,
|
|
10381
|
+
{
|
|
10382
|
+
mutTracker: this.mutTracker,
|
|
10383
|
+
exitMutTracker: this.exitMutTracker
|
|
10384
|
+
}
|
|
10385
|
+
);
|
|
10386
|
+
this.mutTracker.ts = now;
|
|
10387
|
+
this.mutTracker.muts += this.exitMutTracker.muts;
|
|
10388
|
+
this.resetExitTracker();
|
|
10389
|
+
return true;
|
|
10390
|
+
} else {
|
|
10391
|
+
debugLog(`MutationRateLimiter, detected global storm exit.`, {
|
|
10392
|
+
mutTracker: this.mutTracker,
|
|
10393
|
+
exitMutTracker: this.exitMutTracker
|
|
10394
|
+
});
|
|
10395
|
+
this.stormStopped();
|
|
10396
|
+
return false;
|
|
10397
|
+
}
|
|
10398
|
+
}
|
|
10399
|
+
}
|
|
10400
|
+
return true;
|
|
10401
|
+
}
|
|
10402
|
+
canMutationBufferExitMutationStorm() {
|
|
10403
|
+
return !this.inGlobalStorm;
|
|
10404
|
+
}
|
|
10349
10405
|
isStorming(muts) {
|
|
10350
10406
|
const now = Date.now();
|
|
10351
10407
|
if (this.inGlobalStorm) {
|
|
10352
|
-
this.
|
|
10353
|
-
if (now - this.mutTracker.ts > this.interval) {
|
|
10354
|
-
this.inGlobalStorm = false;
|
|
10408
|
+
if (now - this.currentStormStartedAt > this.stormTimeLimit) {
|
|
10355
10409
|
debugLog(
|
|
10356
|
-
`MutationRateLimiter,
|
|
10410
|
+
`MutationRateLimiter, storm time limit reached, stopping storm`
|
|
10357
10411
|
);
|
|
10358
|
-
this.
|
|
10412
|
+
this.stormStopped();
|
|
10359
10413
|
return false;
|
|
10360
10414
|
}
|
|
10415
|
+
if (now - this.mutTracker.ts > this.interval) {
|
|
10416
|
+
return this.handleStormExit(muts);
|
|
10417
|
+
}
|
|
10418
|
+
this.mutTracker.muts += muts;
|
|
10361
10419
|
this.mutTracker.ts = now;
|
|
10362
10420
|
return true;
|
|
10363
10421
|
}
|
|
@@ -10366,9 +10424,10 @@ const _MutationRateLimiter = class _MutationRateLimiter2 {
|
|
|
10366
10424
|
} else {
|
|
10367
10425
|
if (now - this.mutTracker.ts <= this.interval) {
|
|
10368
10426
|
this.mutTracker.muts += muts;
|
|
10369
|
-
if (this.mutTracker.muts >= this.
|
|
10427
|
+
if (this.mutTracker.muts >= this.mutThreshold) {
|
|
10370
10428
|
this.inGlobalStorm = true;
|
|
10371
10429
|
debugLog(`MutationRateLimiter, detected global rolling storm`);
|
|
10430
|
+
this.currentStormStartedAt = now;
|
|
10372
10431
|
return true;
|
|
10373
10432
|
}
|
|
10374
10433
|
}
|
|
@@ -10511,11 +10570,18 @@ class MutationBuffer {
|
|
|
10511
10570
|
__publicField(this, "stormSettings", {
|
|
10512
10571
|
batchSize: 50,
|
|
10513
10572
|
//was 300
|
|
10514
|
-
timeout:
|
|
10573
|
+
timeout: 50,
|
|
10515
10574
|
//was 50
|
|
10516
10575
|
mutationLimit: 800
|
|
10517
10576
|
//was 1500
|
|
10518
10577
|
});
|
|
10578
|
+
__publicField(this, "debounceStormFinish", () => {
|
|
10579
|
+
if (!this.stormInfo) return;
|
|
10580
|
+
this.stormInfo.timeout = setTimeout(
|
|
10581
|
+
this.handleStormFinish,
|
|
10582
|
+
this.stormSettings.timeout
|
|
10583
|
+
);
|
|
10584
|
+
});
|
|
10519
10585
|
__publicField(this, "handleStormMutations", (muts, canFinishStorm = true) => {
|
|
10520
10586
|
const time = Date.now();
|
|
10521
10587
|
if (this.stormInfo == null) {
|
|
@@ -10545,14 +10611,15 @@ class MutationBuffer {
|
|
|
10545
10611
|
if (canFinishStorm && muts.length < this.stormSettings.batchSize) {
|
|
10546
10612
|
this.handleStormFinish();
|
|
10547
10613
|
} else {
|
|
10548
|
-
this.
|
|
10549
|
-
this.handleStormFinish,
|
|
10550
|
-
this.stormSettings.timeout
|
|
10551
|
-
);
|
|
10614
|
+
this.debounceStormFinish();
|
|
10552
10615
|
}
|
|
10553
10616
|
});
|
|
10554
10617
|
__publicField(this, "handleStormFinish", () => {
|
|
10555
10618
|
if (!this.stormInfo) return;
|
|
10619
|
+
if (!mutationRateLimiter.canMutationBufferExitMutationStorm()) {
|
|
10620
|
+
this.debounceStormFinish();
|
|
10621
|
+
return;
|
|
10622
|
+
}
|
|
10556
10623
|
const { stormExceededLimit } = this.stormInfo;
|
|
10557
10624
|
debugLog(
|
|
10558
10625
|
"mutation storm finished",
|