@rotorsoft/act 1.18.1 → 1.18.3

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
@@ -19,7 +19,7 @@ import {
19
19
  sleep,
20
20
  store,
21
21
  validate
22
- } from "./chunk-7XME4ZLK.js";
22
+ } from "./chunk-TODGOWEZ.js";
23
23
  import {
24
24
  ActorSchema,
25
25
  CausationEventSchema,
@@ -44,7 +44,7 @@ import {
44
44
  pii_split,
45
45
  pii_strip,
46
46
  sensitive
47
- } from "./chunk-4TJN4G7L.js";
47
+ } from "./chunk-2RZSKBZZ.js";
48
48
  import "./chunk-YLJ4XMA6.js";
49
49
 
50
50
  // src/signals.ts
@@ -1467,7 +1467,6 @@ async function fetch(leased, eventLimit) {
1467
1467
  }
1468
1468
  var ack = (leases) => store().ack(leases);
1469
1469
  var block = (leases) => store().block(leases);
1470
- var defer = (input, deferred_at) => store().defer(input, deferred_at);
1471
1470
  var subscribe = (streams) => store().subscribe(streams);
1472
1471
 
1473
1472
  // src/internal/event-sourcing.ts
@@ -1497,8 +1496,8 @@ function compute_backoff_delay(retry, opts) {
1497
1496
  // src/internal/event-sourcing.ts
1498
1497
  var DEFAULT_BATCH = 500;
1499
1498
  async function snap(snapshot) {
1499
+ const { id, stream, name, meta, version } = snapshot.event;
1500
1500
  try {
1501
- const { id, stream, name, meta, version } = snapshot.event;
1502
1501
  await store().commit(
1503
1502
  stream,
1504
1503
  [{ name: SNAP_EVENT, data: snapshot.state }],
@@ -1510,7 +1509,10 @@ async function snap(snapshot) {
1510
1509
  // IMPORTANT! - state events are committed right after the snapshot event
1511
1510
  );
1512
1511
  } catch (error) {
1513
- log().error(error);
1512
+ const reason = error instanceof Error ? error.message : String(error);
1513
+ log().warn(
1514
+ `Snapshot write failed on stream "${stream}": ${reason} \u2014 cold starts will replay full history until snapshots succeed.`
1515
+ );
1514
1516
  }
1515
1517
  }
1516
1518
  async function tombstone(stream, expectedVersion, correlation) {
@@ -1945,7 +1947,6 @@ function build_drain(logger) {
1945
1947
  fetch,
1946
1948
  ack,
1947
1949
  block,
1948
- defer,
1949
1950
  subscribe: logger.level !== "trace" ? subscribe : traced(subscribe, (result, streams) => {
1950
1951
  if (!result.subscribed) return;
1951
1952
  const lanes = new Set(streams.map((s) => s.lane ?? "default"));
@@ -2049,21 +2050,13 @@ async function run_drain_cycle(ops, registry, batch_handlers, handle, handle_bat
2049
2050
  })
2050
2051
  );
2051
2052
  const acked = await ops.ack(
2052
- handled.filter((h) => h.defer === void 0 && (h.handled > 0 || !h.error)).map((h) => ({ ...h.lease, at: h.acked_at }))
2053
+ handled.flatMap(
2054
+ (h) => h.defer !== void 0 ? { ...h.lease, due: h.defer } : h.handled > 0 || !h.error ? { ...h.lease, at: h.acked_at } : []
2055
+ )
2053
2056
  );
2054
2057
  const blocked = await ops.block(
2055
2058
  handled.filter(({ block: block2 }) => block2).map(({ lease, error }) => ({ ...lease, error }))
2056
2059
  );
2057
- const deferrals = handled.filter((h) => h.defer !== void 0);
2058
- if (deferrals.length) {
2059
- const by_time = /* @__PURE__ */ new Map();
2060
- for (const h of deferrals) {
2061
- const list = by_time.get(h.defer);
2062
- if (list) list.push(h.lease.stream);
2063
- else by_time.set(h.defer, [h.lease.stream]);
2064
- }
2065
- for (const [at, streams] of by_time) await ops.defer(streams, at);
2066
- }
2067
2060
  const closeable = handled.filter((h) => h.close !== void 0).map((h) => h.close);
2068
2061
  return { leased, fetched, handled, acked, blocked, closeable };
2069
2062
  }