@dudousxd/nestjs-durable 0.49.0 → 0.50.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
@@ -1,4 +1,4 @@
1
- import { WorkflowCtx, SearchAttributes, WorkflowClass, StandardSchemaV1, StepError, OnErrorInput, WorkflowRef, SingletonConfig, ConcurrencyConfig, SearchAttributesSchema, StateStore, Transport, NamedTransport, ControlPlane, ScheduledWorkflow, RetentionPolicy, QueueConfig, AdmissionBackend, WorkflowInputOf, StartOptions, RunResult, RunGateway, WorkflowEngine, EntityHandler, DurableTopology, RunDetailOptions, RunDetail, FanPageQuery, FanPage, RunQuery, RunListItem, RunFacetQuery, RunFacetRow, RunValueAxis, RunValueFacetOptions, RunValueFacetRow, GroupHealth, RunWaiting, EngineEvent, RunRequest, RunReply, StepInvocation, WorkflowRun, TenantEvent } from '@dudousxd/nestjs-durable-core';
1
+ import { WorkflowCtx, SearchAttributes, WorkflowClass, StandardSchemaV1, StepError, OnErrorInput, WorkflowRef, SingletonConfig, ConcurrencyConfig, SearchAttributesSchema, StateStore, Transport, NamedTransport, ControlPlane, StalledRunInfo, ScheduledWorkflow, RetentionPolicy, QueueConfig, AdmissionBackend, WorkflowInputOf, StartOptions, RunResult, RunGateway, WorkflowEngine, EntityHandler, DurableTopology, RunDetailOptions, RunDetail, FanPageQuery, FanPage, RunQuery, RunListItem, RunFacetQuery, RunFacetRow, RunValueAxis, RunValueFacetOptions, RunValueFacetRow, GroupHealth, RunWaiting, EngineEvent, RunRequest, RunReply, StepInvocation, WorkflowRun, TenantEvent } from '@dudousxd/nestjs-durable-core';
2
2
  export { AttributeFilter, DynamicWorkflowCtx, EngineEvent, InferSearchAttributes, OnErrorInput, RunDetail, RunGateway, RunListItem, RunQuery, RunStatus, RunWaiting, SearchAttributes, SearchAttributesSchema, StepCheckpoint, StepEvent, StepLogger, WorkflowCtx, WorkflowEngine, WorkflowHandler, WorkflowRun, readSearchAttributes } from '@dudousxd/nestjs-durable-core';
3
3
  import { z } from 'zod';
4
4
  import { ConcurrencyOption, StartRunDeps, RunRedisWorkerOptions, RunningWorker, DurableWorkerRuntime } from '@dudousxd/durable-worker';
@@ -597,6 +597,19 @@ interface DurableModuleOptions {
597
597
  * See `WorkflowEngineDeps.reconcileMs`. Operator only.
598
598
  */
599
599
  reconcileMs?: number;
600
+ /**
601
+ * Idle time (ms) before a stranded in-flight run is reported to {@link onStalled} listeners.
602
+ * Defaults to 900000 (15 min), floored at 60000. See `WorkflowEngineDeps.stalledAfterMs`.
603
+ * Operator only.
604
+ */
605
+ stalledAfterMs?: number;
606
+ /**
607
+ * Pager hook for stranded runs, registered on the engine as `engine.onStalled(...)`: a run
608
+ * suspended with no wake timer, or parked on an old pending remote step nothing is leasing. The
609
+ * timer poller sweeps once a minute and reports each stranded episode once per instance.
610
+ * Equivalent to calling `engine.onStalled` from a provider; only a DRIVING operator sweeps.
611
+ */
612
+ onStalled?: (info: StalledRunInfo) => void;
600
613
  /**
601
614
  * The most due timers one timer-poll pass loads and drives, most overdue first, so a wave of
602
615
  * thousands of due runs is worked through in batches. Defaults to 500; a non-finite or sub-1 value
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { WorkflowCtx, SearchAttributes, WorkflowClass, StandardSchemaV1, StepError, OnErrorInput, WorkflowRef, SingletonConfig, ConcurrencyConfig, SearchAttributesSchema, StateStore, Transport, NamedTransport, ControlPlane, ScheduledWorkflow, RetentionPolicy, QueueConfig, AdmissionBackend, WorkflowInputOf, StartOptions, RunResult, RunGateway, WorkflowEngine, EntityHandler, DurableTopology, RunDetailOptions, RunDetail, FanPageQuery, FanPage, RunQuery, RunListItem, RunFacetQuery, RunFacetRow, RunValueAxis, RunValueFacetOptions, RunValueFacetRow, GroupHealth, RunWaiting, EngineEvent, RunRequest, RunReply, StepInvocation, WorkflowRun, TenantEvent } from '@dudousxd/nestjs-durable-core';
1
+ import { WorkflowCtx, SearchAttributes, WorkflowClass, StandardSchemaV1, StepError, OnErrorInput, WorkflowRef, SingletonConfig, ConcurrencyConfig, SearchAttributesSchema, StateStore, Transport, NamedTransport, ControlPlane, StalledRunInfo, ScheduledWorkflow, RetentionPolicy, QueueConfig, AdmissionBackend, WorkflowInputOf, StartOptions, RunResult, RunGateway, WorkflowEngine, EntityHandler, DurableTopology, RunDetailOptions, RunDetail, FanPageQuery, FanPage, RunQuery, RunListItem, RunFacetQuery, RunFacetRow, RunValueAxis, RunValueFacetOptions, RunValueFacetRow, GroupHealth, RunWaiting, EngineEvent, RunRequest, RunReply, StepInvocation, WorkflowRun, TenantEvent } from '@dudousxd/nestjs-durable-core';
2
2
  export { AttributeFilter, DynamicWorkflowCtx, EngineEvent, InferSearchAttributes, OnErrorInput, RunDetail, RunGateway, RunListItem, RunQuery, RunStatus, RunWaiting, SearchAttributes, SearchAttributesSchema, StepCheckpoint, StepEvent, StepLogger, WorkflowCtx, WorkflowEngine, WorkflowHandler, WorkflowRun, readSearchAttributes } from '@dudousxd/nestjs-durable-core';
3
3
  import { z } from 'zod';
4
4
  import { ConcurrencyOption, StartRunDeps, RunRedisWorkerOptions, RunningWorker, DurableWorkerRuntime } from '@dudousxd/durable-worker';
@@ -597,6 +597,19 @@ interface DurableModuleOptions {
597
597
  * See `WorkflowEngineDeps.reconcileMs`. Operator only.
598
598
  */
599
599
  reconcileMs?: number;
600
+ /**
601
+ * Idle time (ms) before a stranded in-flight run is reported to {@link onStalled} listeners.
602
+ * Defaults to 900000 (15 min), floored at 60000. See `WorkflowEngineDeps.stalledAfterMs`.
603
+ * Operator only.
604
+ */
605
+ stalledAfterMs?: number;
606
+ /**
607
+ * Pager hook for stranded runs, registered on the engine as `engine.onStalled(...)`: a run
608
+ * suspended with no wake timer, or parked on an old pending remote step nothing is leasing. The
609
+ * timer poller sweeps once a minute and reports each stranded episode once per instance.
610
+ * Equivalent to calling `engine.onStalled` from a provider; only a DRIVING operator sweeps.
611
+ */
612
+ onStalled?: (info: StalledRunInfo) => void;
600
613
  /**
601
614
  * The most due timers one timer-poll pass loads and drives, most overdue first, so a wave of
602
615
  * thousands of due runs is worked through in batches. Defaults to 500; a non-finite or sub-1 value
package/dist/index.js CHANGED
@@ -2186,6 +2186,7 @@ var TimerPoller = class {
2186
2186
  await this.sweep("recoverIncomplete", () => this.engine.recoverIncomplete());
2187
2187
  await this.sweep("resumeDueTimers", () => this.engine.resumeDueTimers());
2188
2188
  await this.sweep("sweepTimeouts", () => this.engine.sweepTimeouts());
2189
+ await this.sweep("sweepStalled", async () => this.engine.sweepStalled?.());
2189
2190
  const schedules = this.options.schedules;
2190
2191
  if (schedules && schedules.length > 0) {
2191
2192
  await this.sweep("schedules", () => runSchedules(this.engine, schedules, Date.now()));
@@ -2884,6 +2885,7 @@ var DurableModule = class _DurableModule {
2884
2885
  remoteRedispatchMs: options.remoteRedispatchMs,
2885
2886
  remoteRedispatchMax: options.remoteRedispatchMax,
2886
2887
  reconcileMs: options.reconcileMs,
2888
+ stalledAfterMs: options.stalledAfterMs,
2887
2889
  timerBatchSize: options.timerBatchSize,
2888
2890
  eventBufferTtlMs: options.eventBufferTtlMs,
2889
2891
  blockedPollMs: options.blockedPollMs,
@@ -2907,6 +2909,7 @@ var DurableModule = class _DurableModule {
2907
2909
  } : void 0
2908
2910
  });
2909
2911
  for (const queue of options.queues ?? []) engine.registerQueue(queue);
2912
+ if (options.onStalled) engine.onStalled(options.onStalled);
2910
2913
  return engine;
2911
2914
  }, "useFactory"),
2912
2915
  inject: [