@resolveio/server-lib 20.14.22 → 20.14.24

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.
@@ -101,6 +101,7 @@ export declare class SubscriptionManager {
101
101
  private parseBoolean;
102
102
  private clampNumber;
103
103
  private ensureWarmupAdaptiveMonitor;
104
+ private maybeDisableWarmup;
104
105
  private normalizePressure;
105
106
  private sampleCpuPercent;
106
107
  private sampleWarmupAdaptiveMetrics;
@@ -440,9 +440,9 @@ var SubscriptionManager = /** @class */ (function () {
440
440
  this._warmupEnabled = false;
441
441
  return;
442
442
  }
443
- var durationMs = warmupMs || 60000;
443
+ var durationMs = warmupMs;
444
444
  this._warmupEnabled = true;
445
- this._warmupEndsAtMs = Date.now() + durationMs;
445
+ this._warmupEndsAtMs = durationMs > 0 ? Date.now() + durationMs : 0;
446
446
  this._warmupTickMs = this.parsePositiveNumber((_c = process.env.SUBSCRIPTION_WARMUP_TICK_MS) !== null && _c !== void 0 ? _c : config['SUBSCRIPTION_WARMUP_TICK_MS']) || this._warmupTickMs;
447
447
  this._warmupMaxPerTick = this.parsePositiveNumber((_d = process.env.SUBSCRIPTION_WARMUP_MAX_PER_TICK) !== null && _d !== void 0 ? _d : config['SUBSCRIPTION_WARMUP_MAX_PER_TICK']) || this._warmupMaxPerTick;
448
448
  this._warmupMaxInFlight = this.parsePositiveNumber((_e = process.env.SUBSCRIPTION_WARMUP_MAX_IN_FLIGHT) !== null && _e !== void 0 ? _e : config['SUBSCRIPTION_WARMUP_MAX_IN_FLIGHT']) || Math.max(1, this._warmupMaxPerTick);
@@ -475,7 +475,7 @@ var SubscriptionManager = /** @class */ (function () {
475
475
  }
476
476
  this.startWarmupTimer();
477
477
  console.log(new Date(), 'Sub Manager', 'Warmup enabled', {
478
- durationMs: durationMs,
478
+ minDurationMs: durationMs,
479
479
  tickMs: this._warmupTickMs,
480
480
  maxPerTick: this._warmupMaxPerTick,
481
481
  maxInFlight: this._warmupMaxInFlight,
@@ -536,6 +536,28 @@ var SubscriptionManager = /** @class */ (function () {
536
536
  this._warmupCpuSampleAt = process.hrtime.bigint();
537
537
  this._warmupAdaptiveLastSampleAt = Date.now();
538
538
  };
539
+ SubscriptionManager.prototype.maybeDisableWarmup = function (nowMs) {
540
+ if (!this._warmupEnabled) {
541
+ return;
542
+ }
543
+ if (this._warmupQueue.length > 0 || this._warmupInFlight > 0) {
544
+ return;
545
+ }
546
+ if (this._warmupEndsAtMs > 0 && nowMs < this._warmupEndsAtMs) {
547
+ return;
548
+ }
549
+ this._warmupEnabled = false;
550
+ this._warmupAdaptiveScale = 0;
551
+ this._warmupAdaptiveLastSampleAt = 0;
552
+ if (this._warmupLagMonitor) {
553
+ this._warmupLagMonitor.disable();
554
+ this._warmupLagMonitor = null;
555
+ }
556
+ console.log(new Date(), 'Sub Manager', 'Warmup complete', {
557
+ queued: this._warmupQueue.length,
558
+ inFlight: this._warmupInFlight
559
+ });
560
+ };
539
561
  SubscriptionManager.prototype.normalizePressure = function (value, target, max) {
540
562
  if (!Number.isFinite(value)) {
541
563
  return 0;
@@ -693,6 +715,7 @@ var SubscriptionManager = /** @class */ (function () {
693
715
  }
694
716
  clearInterval(this._warmupTimer);
695
717
  this._warmupTimer = null;
718
+ this.maybeDisableWarmup(Date.now());
696
719
  };
697
720
  SubscriptionManager.prototype.processWarmupQueue = function () {
698
721
  return __awaiter(this, void 0, void 0, function () {
@@ -710,7 +733,7 @@ var SubscriptionManager = /** @class */ (function () {
710
733
  _b.trys.push([1, , 4, 5]);
711
734
  pendingTasks = [];
712
735
  now = Date.now();
713
- if (this._warmupEnabled && now >= this._warmupEndsAtMs && !this._warmupWindowEndedLogged) {
736
+ if (this._warmupEnabled && this._warmupEndsAtMs > 0 && now >= this._warmupEndsAtMs && !this._warmupWindowEndedLogged) {
714
737
  this._warmupWindowEndedLogged = true;
715
738
  console.log(new Date(), 'Sub Manager', 'Warmup minimum window ended', {
716
739
  queued: this._warmupQueue.length
@@ -835,6 +858,9 @@ var SubscriptionManager = /** @class */ (function () {
835
858
  };
836
859
  SubscriptionManager.prototype.logWarmupStatus = function (reason, limits) {
837
860
  var _a, _b, _c;
861
+ if (!this._enableDebug) {
862
+ return;
863
+ }
838
864
  if (!this._warmupLogIntervalMs) {
839
865
  return;
840
866
  }