@rotorsoft/act 1.23.8 → 1.23.10

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
@@ -20,7 +20,7 @@ import {
20
20
  sleep,
21
21
  store,
22
22
  validate
23
- } from "./chunk-7PG2SR37.js";
23
+ } from "./chunk-T722JHPU.js";
24
24
  import {
25
25
  ActorSchema,
26
26
  CausationEventSchema,
@@ -1750,9 +1750,14 @@ var DeferTimer = class {
1750
1750
  this._timer = setTimeout(() => {
1751
1751
  this._timer = void 0;
1752
1752
  const now = Date.now();
1753
+ let came_due = false;
1753
1754
  for (const [stream, at] of this._due)
1754
- if (at <= now) this._due.delete(stream);
1755
+ if (at <= now) {
1756
+ this._due.delete(stream);
1757
+ came_due = true;
1758
+ }
1755
1759
  this._on_wake();
1760
+ if (!came_due && this._due.size > 0) this.schedule();
1756
1761
  }, delay);
1757
1762
  this._timer.unref();
1758
1763
  }
@@ -2426,9 +2431,10 @@ async function run_drain_cycle(ops, registry, batch_handlers, handle, handle_bat
2426
2431
  })
2427
2432
  );
2428
2433
  const acked = await ops.ack(
2429
- handled.flatMap(
2430
- (h) => h.defer !== void 0 ? { ...h.lease, due: h.defer, retry: -1 } : h.handled > 0 || !h.error ? { ...h.lease, at: h.acked_at } : h.next_attempt_at !== void 0 ? { ...h.lease, due: h.next_attempt_at } : []
2431
- )
2434
+ handled.flatMap((h, i) => {
2435
+ const advance = h.handled > 0 ? h.acked_at : leased[i].at;
2436
+ return h.defer !== void 0 ? { ...h.lease, at: advance, due: h.defer, retry: -1 } : h.next_attempt_at !== void 0 ? { ...h.lease, at: advance, due: h.next_attempt_at } : h.handled > 0 || !h.error ? { ...h.lease, at: h.acked_at } : [];
2437
+ })
2432
2438
  );
2433
2439
  const blocked = await ops.block(
2434
2440
  handled.filter(({ block: block2 }) => block2).map(({ lease, error }) => ({ ...lease, error }))