@rotorsoft/act 1.31.18 → 1.31.19

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/index.js CHANGED
@@ -3811,13 +3811,13 @@ var Act = class {
3811
3811
  resolveShutdownConfig(options);
3812
3812
  this._shutdown_promise = (async () => {
3813
3813
  this.stop_correlations();
3814
- await this._scoped(() => this._correlate.release_correlation());
3815
3814
  const disposer = await this._notify_disposer;
3816
3815
  if (disposer) await disposer();
3817
3816
  this.stop_settling();
3818
3817
  this._breaker.stop();
3819
3818
  for (const c of this._drain_controllers.values()) c.stop();
3820
3819
  await this._await_inflight(options?.graceMs);
3820
+ await this._scoped(() => this._correlate.release_correlation());
3821
3821
  this._emitter.removeAllListeners();
3822
3822
  })();
3823
3823
  }
@@ -3835,9 +3835,14 @@ var Act = class {
3835
3835
  * lane that pinned no lease contributes `drain()`'s own fallback, and the
3836
3836
  * whole thing is capped so a long-leased lane cannot hold a deploy open.
3837
3837
  * Idle lanes do not count — nothing is running on them to wait for.
3838
+ *
3839
+ * An in-flight settle counts the same way, on the same fallback (#1617).
3840
+ * It is waited on like any cycle, and deriving from the lanes alone gave
3841
+ * it a budget of `0` whenever it was the only thing running — which
3842
+ * returned before the wait it was about to be added to.
3838
3843
  */
3839
- _derive_grace_ms(running) {
3840
- let max = 0;
3844
+ _derive_grace_ms(running, settling) {
3845
+ let max = settling ? DEFAULT_SHUTDOWN_GRACE_MS : 0;
3841
3846
  for (const c of running)
3842
3847
  max = Math.max(max, c.lease_millis ?? DEFAULT_SHUTDOWN_GRACE_MS);
3843
3848
  return Math.min(max, MAX_SHUTDOWN_GRACE_MS);
@@ -3848,7 +3853,7 @@ var Act = class {
3848
3853
  );
3849
3854
  const settling = this._settle.inflight;
3850
3855
  if (running.length === 0 && !settling) return;
3851
- const grace = grace_ms ?? this._derive_grace_ms(running);
3856
+ const grace = grace_ms ?? this._derive_grace_ms(running, !!settling);
3852
3857
  if (grace <= 0) return;
3853
3858
  const inflight = running.map((c) => c.inflight);
3854
3859
  if (settling) inflight.push(settling);