@rotorsoft/act 1.32.8 → 1.32.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
@@ -2849,6 +2849,16 @@ function budget_exhausted(lease, options, store_failing) {
2849
2849
  log().error(error);
2850
2850
  return { lease, handled: 0, acked_at: lease.at, error, block: true };
2851
2851
  }
2852
+ function fetch_failure_policy(registry) {
2853
+ let blockOnError = true;
2854
+ let maxRetries = 0;
2855
+ for (const register of Object.values(registry.events))
2856
+ for (const reaction of register.reactions.values()) {
2857
+ blockOnError &&= reaction.options.blockOnError;
2858
+ maxRetries = Math.max(maxRetries, reaction.options.maxRetries);
2859
+ }
2860
+ return { blockOnError, maxRetries };
2861
+ }
2852
2862
  function warn_misrouted(seen, stream, handler, event) {
2853
2863
  report_once(
2854
2864
  seen,
@@ -2899,11 +2909,14 @@ async function run_drain_cycle(ops, registry, batch_handlers, misrouted, store_f
2899
2909
  if (entry.fetch.error !== void 0) {
2900
2910
  const error = `Fetch failed for ${lease.stream}: ${entry.fetch.error}`;
2901
2911
  log().error(error);
2912
+ const policy = fetch_failure_policy(registry);
2913
+ const block2 = !store_failing && policy.blockOnError && lease.retry >= policy.maxRetries;
2902
2914
  const failed = {
2903
2915
  lease,
2904
2916
  handled: 0,
2905
2917
  acked_at: lease.at,
2906
- error
2918
+ error,
2919
+ ...block2 ? { block: true } : {}
2907
2920
  };
2908
2921
  return Promise.resolve(failed);
2909
2922
  }
@@ -3419,9 +3432,13 @@ function build_handle(deps) {
3419
3432
  function build_handle_batch(logger) {
3420
3433
  return async (lease, payloads, batchHandler) => {
3421
3434
  const stream = lease.stream;
3422
- const events = payloads.map(
3423
- (p) => p.event
3424
- );
3435
+ const events = [];
3436
+ const seen = /* @__PURE__ */ new Set();
3437
+ for (const p of payloads) {
3438
+ if (seen.has(p.event.id)) continue;
3439
+ seen.add(p.event.id);
3440
+ events.push(p.event);
3441
+ }
3425
3442
  const options = payloads[0].options;
3426
3443
  if (lease.retry > 0)
3427
3444
  logger.warn(`Retrying batch ${stream}@${events[0].id} (${lease.retry}).`);
@@ -5374,6 +5391,7 @@ function act() {
5374
5391
  const pending_projections = [];
5375
5392
  const projection_reactions = /* @__PURE__ */ new Set();
5376
5393
  const record_projection_reactions = (proj) => {
5394
+ if (!proj.batchHandler && !proj.fold) return;
5377
5395
  for (const register of Object.values(
5378
5396
  proj.events
5379
5397
  ))