@dudousxd/nestjs-durable 0.43.1 → 0.44.0

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.d.cts CHANGED
@@ -464,6 +464,26 @@ interface DurableModuleOptions {
464
464
  * Operator only.
465
465
  */
466
466
  remoteAdvanceSilenceMs?: number;
467
+ /**
468
+ * Opt-in self-heal window (ms) for a dispatched remote step whose job was LOST — the worker was
469
+ * killed mid-step (an OOM kill leaves no result, and a non-TS consumer has no way to bridge the
470
+ * job's terminal failure back into one), or the broker dropped the job. The `pending` checkpoint
471
+ * then has nothing left to settle it, so the run waits forever. When set, the pending checkpoint
472
+ * carries a LEASE: a result — or a step-scoped heartbeat, which renews it, so a worker still
473
+ * holding the step is never double-dispatched — must land within the window, else the engine
474
+ * re-dispatches the same step (bumping `attempts`, bounded by {@link remoteRedispatchMax}).
475
+ * Covers both `ctx.step` and a polyglot workflow's `call` fan-out (`ctx.gather_calls`).
476
+ *
477
+ * Off by default: a re-dispatch double-runs a step whose original job was merely SLOW, so the
478
+ * window MUST exceed your longest remote step and the step MUST be idempotent. Operator only.
479
+ */
480
+ remoteRedispatchMs?: number;
481
+ /**
482
+ * Max times {@link remoteRedispatchMs} re-dispatches one lost step before failing it
483
+ * (`remote_step_lost`, surfaced on the run) instead of re-dispatching forever. Defaults to 10.
484
+ * Ignored when `remoteRedispatchMs` is unset. Operator only.
485
+ */
486
+ remoteRedispatchMax?: number;
467
487
  /**
468
488
  * The **default** workflow to route dead-lettered runs to, for workflows that don't declare their
469
489
  * own. When a run is moved to `dead` (exceeded `maxRecoveryAttempts`), the started handler gets a
@@ -708,6 +728,12 @@ declare class DurableStartClient {
708
728
  * fake so no real Redis is needed.
709
729
  */
710
730
  declare const RUN_REDIS_WORKER: unique symbol;
731
+ /**
732
+ * The store-less {@link DurableWorkerRuntime} a pure thin worker registers its bodies on — `null` in
733
+ * every other role. A Symbol rather than the class itself: the class lives in an optional peer, and
734
+ * using it as a DI token would drag that peer into the package's static import graph.
735
+ */
736
+ declare const DURABLE_WORKER_RUNTIME: unique symbol;
711
737
  /** The list of started {@link RunningWorker} handles (the single handle {@link ThinWorkerBootstrap}
712
738
  * starts), closed on shutdown. */
713
739
  declare const DURABLE_WORKER_RUNNERS: unique symbol;
@@ -724,7 +750,7 @@ declare class ThinWorkflowRegistrar implements OnModuleInit {
724
750
  private readonly discovery;
725
751
  private readonly runtime;
726
752
  private readonly options;
727
- constructor(discovery: DiscoveryService, runtime: DurableWorkerRuntime, options: DurableModuleOptions);
753
+ constructor(discovery: DiscoveryService, runtime: DurableWorkerRuntime | null, options: DurableModuleOptions);
728
754
  onModuleInit(): void;
729
755
  }
730
756
  /**
@@ -738,7 +764,7 @@ declare class ThinStepRegistrar implements OnModuleInit {
738
764
  private readonly metadataScanner;
739
765
  private readonly runtime;
740
766
  private readonly options;
741
- constructor(discovery: DiscoveryService, metadataScanner: MetadataScanner, runtime: DurableWorkerRuntime, options: DurableModuleOptions);
767
+ constructor(discovery: DiscoveryService, metadataScanner: MetadataScanner, runtime: DurableWorkerRuntime | null, options: DurableModuleOptions);
742
768
  onModuleInit(): void;
743
769
  }
744
770
  /**
@@ -757,7 +783,7 @@ declare class ThinWorkerBootstrap implements OnApplicationBootstrap, OnApplicati
757
783
  private readonly runRedisWorker;
758
784
  private readonly runnersSink;
759
785
  private readonly runners;
760
- constructor(runtime: DurableWorkerRuntime, options: DurableModuleOptions, runRedisWorker: RunRedisWorkerFn, runnersSink: RunningWorker[]);
786
+ constructor(runtime: DurableWorkerRuntime | null, options: DurableModuleOptions, runRedisWorker: RunRedisWorkerFn, runnersSink: RunningWorker[]);
761
787
  onApplicationBootstrap(): Promise<void>;
762
788
  onApplicationShutdown(): Promise<void>;
763
789
  }
@@ -864,7 +890,7 @@ declare class InAppWorkerBootstrap implements OnModuleInit, OnApplicationBootstr
864
890
  private readonly runRedisWorker;
865
891
  private readonly runnersSink;
866
892
  private readonly runners;
867
- constructor(discovery: DiscoveryService, metadataScanner: MetadataScanner, options: DurableModuleOptions, runtime: DurableWorkerRuntime, runRedisWorker: RunRedisWorkerFn, runnersSink: RunningWorker[]);
893
+ constructor(discovery: DiscoveryService, metadataScanner: MetadataScanner, options: DurableModuleOptions, runtime: DurableWorkerRuntime | null, runRedisWorker: RunRedisWorkerFn, runnersSink: RunningWorker[]);
868
894
  onModuleInit(): void;
869
895
  onApplicationBootstrap(): Promise<void>;
870
896
  onApplicationShutdown(): Promise<void>;
@@ -1150,4 +1176,4 @@ declare class WorkflowService {
1150
1176
  }): Promise<number>;
1151
1177
  }
1152
1178
 
1153
- export { CONTEXT_ACCESSOR, type ContextAccessor, type ContextStore, DEAD_LETTER_METADATA, DURABLE_STEP_METADATA, DURABLE_WORKER_RUNNERS, DeadLetter, DurableModule, type DurableModuleAsyncOptions, type DurableModuleOptions, type DurableRetentionOptions, DurableStartClient, DurableStep, type DurableStepInterceptor, type DurableStepMeta, ENTITY_METADATA, ENTITY_ON_METADATA, Entity, EntityService, IN_APP_RUN_REDIS_WORKER, IN_APP_WORKER_BINDING, IN_APP_WORKER_RUNNERS, IN_APP_WORKER_RUNTIME, type InAppWorkerBinding, InAppWorkerBootstrap, ON_EVENT_METADATA, On, OnDurableEvent, OnEvent, ProxyRunGateway, RUN_GATEWAY, RUN_REDIS_WORKER, type RunLookupStore, type RunRedisWorkerFn, RunRequestResponder, type RunRequestTransport, STEP_INTERCEPTOR_METADATA, Step, StepInterceptor, type StepOptions, StoreRunGateway, TenantEventRepublisher, ThinStepRegistrar, ThinWorkerBootstrap, ThinWorkflowRegistrar, type UserRef, WORKFLOW_METADATA, Workflow, type WorkflowAttributesOf, type WorkflowMeta, type WorkflowOptions, WorkflowService, attributesOf, entityConfigFor, getDurableStepMeta, getEntityMeta, getOnEvents, getWorkflowMeta, inAppWorkerProviders, isDeadLetterHandler, isDrivingOperator, isOperatorRole, isStepInterceptor, thinWorkerProviders, unavailableRunGateway };
1179
+ export { CONTEXT_ACCESSOR, type ContextAccessor, type ContextStore, DEAD_LETTER_METADATA, DURABLE_STEP_METADATA, DURABLE_WORKER_RUNNERS, DURABLE_WORKER_RUNTIME, DeadLetter, DurableModule, type DurableModuleAsyncOptions, type DurableModuleOptions, type DurableRetentionOptions, DurableStartClient, DurableStep, type DurableStepInterceptor, type DurableStepMeta, ENTITY_METADATA, ENTITY_ON_METADATA, Entity, EntityService, IN_APP_RUN_REDIS_WORKER, IN_APP_WORKER_BINDING, IN_APP_WORKER_RUNNERS, IN_APP_WORKER_RUNTIME, type InAppWorkerBinding, InAppWorkerBootstrap, ON_EVENT_METADATA, On, OnDurableEvent, OnEvent, ProxyRunGateway, RUN_GATEWAY, RUN_REDIS_WORKER, type RunLookupStore, type RunRedisWorkerFn, RunRequestResponder, type RunRequestTransport, STEP_INTERCEPTOR_METADATA, Step, StepInterceptor, type StepOptions, StoreRunGateway, TenantEventRepublisher, ThinStepRegistrar, ThinWorkerBootstrap, ThinWorkflowRegistrar, type UserRef, WORKFLOW_METADATA, Workflow, type WorkflowAttributesOf, type WorkflowMeta, type WorkflowOptions, WorkflowService, attributesOf, entityConfigFor, getDurableStepMeta, getEntityMeta, getOnEvents, getWorkflowMeta, inAppWorkerProviders, isDeadLetterHandler, isDrivingOperator, isOperatorRole, isStepInterceptor, thinWorkerProviders, unavailableRunGateway };
package/dist/index.d.ts CHANGED
@@ -464,6 +464,26 @@ interface DurableModuleOptions {
464
464
  * Operator only.
465
465
  */
466
466
  remoteAdvanceSilenceMs?: number;
467
+ /**
468
+ * Opt-in self-heal window (ms) for a dispatched remote step whose job was LOST — the worker was
469
+ * killed mid-step (an OOM kill leaves no result, and a non-TS consumer has no way to bridge the
470
+ * job's terminal failure back into one), or the broker dropped the job. The `pending` checkpoint
471
+ * then has nothing left to settle it, so the run waits forever. When set, the pending checkpoint
472
+ * carries a LEASE: a result — or a step-scoped heartbeat, which renews it, so a worker still
473
+ * holding the step is never double-dispatched — must land within the window, else the engine
474
+ * re-dispatches the same step (bumping `attempts`, bounded by {@link remoteRedispatchMax}).
475
+ * Covers both `ctx.step` and a polyglot workflow's `call` fan-out (`ctx.gather_calls`).
476
+ *
477
+ * Off by default: a re-dispatch double-runs a step whose original job was merely SLOW, so the
478
+ * window MUST exceed your longest remote step and the step MUST be idempotent. Operator only.
479
+ */
480
+ remoteRedispatchMs?: number;
481
+ /**
482
+ * Max times {@link remoteRedispatchMs} re-dispatches one lost step before failing it
483
+ * (`remote_step_lost`, surfaced on the run) instead of re-dispatching forever. Defaults to 10.
484
+ * Ignored when `remoteRedispatchMs` is unset. Operator only.
485
+ */
486
+ remoteRedispatchMax?: number;
467
487
  /**
468
488
  * The **default** workflow to route dead-lettered runs to, for workflows that don't declare their
469
489
  * own. When a run is moved to `dead` (exceeded `maxRecoveryAttempts`), the started handler gets a
@@ -708,6 +728,12 @@ declare class DurableStartClient {
708
728
  * fake so no real Redis is needed.
709
729
  */
710
730
  declare const RUN_REDIS_WORKER: unique symbol;
731
+ /**
732
+ * The store-less {@link DurableWorkerRuntime} a pure thin worker registers its bodies on — `null` in
733
+ * every other role. A Symbol rather than the class itself: the class lives in an optional peer, and
734
+ * using it as a DI token would drag that peer into the package's static import graph.
735
+ */
736
+ declare const DURABLE_WORKER_RUNTIME: unique symbol;
711
737
  /** The list of started {@link RunningWorker} handles (the single handle {@link ThinWorkerBootstrap}
712
738
  * starts), closed on shutdown. */
713
739
  declare const DURABLE_WORKER_RUNNERS: unique symbol;
@@ -724,7 +750,7 @@ declare class ThinWorkflowRegistrar implements OnModuleInit {
724
750
  private readonly discovery;
725
751
  private readonly runtime;
726
752
  private readonly options;
727
- constructor(discovery: DiscoveryService, runtime: DurableWorkerRuntime, options: DurableModuleOptions);
753
+ constructor(discovery: DiscoveryService, runtime: DurableWorkerRuntime | null, options: DurableModuleOptions);
728
754
  onModuleInit(): void;
729
755
  }
730
756
  /**
@@ -738,7 +764,7 @@ declare class ThinStepRegistrar implements OnModuleInit {
738
764
  private readonly metadataScanner;
739
765
  private readonly runtime;
740
766
  private readonly options;
741
- constructor(discovery: DiscoveryService, metadataScanner: MetadataScanner, runtime: DurableWorkerRuntime, options: DurableModuleOptions);
767
+ constructor(discovery: DiscoveryService, metadataScanner: MetadataScanner, runtime: DurableWorkerRuntime | null, options: DurableModuleOptions);
742
768
  onModuleInit(): void;
743
769
  }
744
770
  /**
@@ -757,7 +783,7 @@ declare class ThinWorkerBootstrap implements OnApplicationBootstrap, OnApplicati
757
783
  private readonly runRedisWorker;
758
784
  private readonly runnersSink;
759
785
  private readonly runners;
760
- constructor(runtime: DurableWorkerRuntime, options: DurableModuleOptions, runRedisWorker: RunRedisWorkerFn, runnersSink: RunningWorker[]);
786
+ constructor(runtime: DurableWorkerRuntime | null, options: DurableModuleOptions, runRedisWorker: RunRedisWorkerFn, runnersSink: RunningWorker[]);
761
787
  onApplicationBootstrap(): Promise<void>;
762
788
  onApplicationShutdown(): Promise<void>;
763
789
  }
@@ -864,7 +890,7 @@ declare class InAppWorkerBootstrap implements OnModuleInit, OnApplicationBootstr
864
890
  private readonly runRedisWorker;
865
891
  private readonly runnersSink;
866
892
  private readonly runners;
867
- constructor(discovery: DiscoveryService, metadataScanner: MetadataScanner, options: DurableModuleOptions, runtime: DurableWorkerRuntime, runRedisWorker: RunRedisWorkerFn, runnersSink: RunningWorker[]);
893
+ constructor(discovery: DiscoveryService, metadataScanner: MetadataScanner, options: DurableModuleOptions, runtime: DurableWorkerRuntime | null, runRedisWorker: RunRedisWorkerFn, runnersSink: RunningWorker[]);
868
894
  onModuleInit(): void;
869
895
  onApplicationBootstrap(): Promise<void>;
870
896
  onApplicationShutdown(): Promise<void>;
@@ -1150,4 +1176,4 @@ declare class WorkflowService {
1150
1176
  }): Promise<number>;
1151
1177
  }
1152
1178
 
1153
- export { CONTEXT_ACCESSOR, type ContextAccessor, type ContextStore, DEAD_LETTER_METADATA, DURABLE_STEP_METADATA, DURABLE_WORKER_RUNNERS, DeadLetter, DurableModule, type DurableModuleAsyncOptions, type DurableModuleOptions, type DurableRetentionOptions, DurableStartClient, DurableStep, type DurableStepInterceptor, type DurableStepMeta, ENTITY_METADATA, ENTITY_ON_METADATA, Entity, EntityService, IN_APP_RUN_REDIS_WORKER, IN_APP_WORKER_BINDING, IN_APP_WORKER_RUNNERS, IN_APP_WORKER_RUNTIME, type InAppWorkerBinding, InAppWorkerBootstrap, ON_EVENT_METADATA, On, OnDurableEvent, OnEvent, ProxyRunGateway, RUN_GATEWAY, RUN_REDIS_WORKER, type RunLookupStore, type RunRedisWorkerFn, RunRequestResponder, type RunRequestTransport, STEP_INTERCEPTOR_METADATA, Step, StepInterceptor, type StepOptions, StoreRunGateway, TenantEventRepublisher, ThinStepRegistrar, ThinWorkerBootstrap, ThinWorkflowRegistrar, type UserRef, WORKFLOW_METADATA, Workflow, type WorkflowAttributesOf, type WorkflowMeta, type WorkflowOptions, WorkflowService, attributesOf, entityConfigFor, getDurableStepMeta, getEntityMeta, getOnEvents, getWorkflowMeta, inAppWorkerProviders, isDeadLetterHandler, isDrivingOperator, isOperatorRole, isStepInterceptor, thinWorkerProviders, unavailableRunGateway };
1179
+ export { CONTEXT_ACCESSOR, type ContextAccessor, type ContextStore, DEAD_LETTER_METADATA, DURABLE_STEP_METADATA, DURABLE_WORKER_RUNNERS, DURABLE_WORKER_RUNTIME, DeadLetter, DurableModule, type DurableModuleAsyncOptions, type DurableModuleOptions, type DurableRetentionOptions, DurableStartClient, DurableStep, type DurableStepInterceptor, type DurableStepMeta, ENTITY_METADATA, ENTITY_ON_METADATA, Entity, EntityService, IN_APP_RUN_REDIS_WORKER, IN_APP_WORKER_BINDING, IN_APP_WORKER_RUNNERS, IN_APP_WORKER_RUNTIME, type InAppWorkerBinding, InAppWorkerBootstrap, ON_EVENT_METADATA, On, OnDurableEvent, OnEvent, ProxyRunGateway, RUN_GATEWAY, RUN_REDIS_WORKER, type RunLookupStore, type RunRedisWorkerFn, RunRequestResponder, type RunRequestTransport, STEP_INTERCEPTOR_METADATA, Step, StepInterceptor, type StepOptions, StoreRunGateway, TenantEventRepublisher, ThinStepRegistrar, ThinWorkerBootstrap, ThinWorkflowRegistrar, type UserRef, WORKFLOW_METADATA, Workflow, type WorkflowAttributesOf, type WorkflowMeta, type WorkflowOptions, WorkflowService, attributesOf, entityConfigFor, getDurableStepMeta, getEntityMeta, getOnEvents, getWorkflowMeta, inAppWorkerProviders, isDeadLetterHandler, isDrivingOperator, isOperatorRole, isStepInterceptor, thinWorkerProviders, unavailableRunGateway };