@dudousxd/nestjs-durable-core 0.49.1 → 0.49.2

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.cjs CHANGED
@@ -1801,6 +1801,7 @@ var WorkflowEngine = class {
1801
1801
  leaseMs;
1802
1802
  maxRecoveryAttempts;
1803
1803
  remoteAdvanceSilenceMs;
1804
+ reconcileMs;
1804
1805
  webhookUrl;
1805
1806
  traceparent;
1806
1807
  context;
@@ -1871,6 +1872,7 @@ var WorkflowEngine = class {
1871
1872
  this.leaseMs = deps.leaseMs ?? 3e4;
1872
1873
  this.maxRecoveryAttempts = deps.maxRecoveryAttempts;
1873
1874
  this.remoteAdvanceSilenceMs = deps.remoteAdvanceSilenceMs;
1875
+ this.reconcileMs = deps.reconcileMs === void 0 ? 3e5 : deps.reconcileMs || void 0;
1874
1876
  this.webhookUrl = deps.webhookUrl;
1875
1877
  this.traceparent = deps.traceparent;
1876
1878
  this.context = deps.context;
@@ -3215,7 +3217,7 @@ var WorkflowEngine = class {
3215
3217
  }
3216
3218
  await this.store.updateRun(run.id, {
3217
3219
  status: "suspended",
3218
- wakeAt: outcome.wakeAt,
3220
+ wakeAt: this.reconcileWakeAt(outcome.wakeAt),
3219
3221
  updatedAt
3220
3222
  });
3221
3223
  this.emit({
@@ -3229,6 +3231,16 @@ var WorkflowEngine = class {
3229
3231
  status: "suspended"
3230
3232
  };
3231
3233
  }
3234
+ /**
3235
+ * A wakeAt to persist on a suspend: the natural timer if the turn produced one (a `ctx.sleep`, a
3236
+ * remote-step deadline), else the {@link reconcileMs} fallback so an event-waiting run (child/signal/
3237
+ * timeout-less remote step) can't be orphaned forever if its wake is lost. `undefined` only when the
3238
+ * fallback is disabled (`reconcileMs: 0`). See {@link WorkflowEngineDeps.reconcileMs}.
3239
+ */
3240
+ reconcileWakeAt(wakeAt) {
3241
+ if (wakeAt != null) return wakeAt;
3242
+ return this.reconcileMs != null ? this.clock() + this.reconcileMs : void 0;
3243
+ }
3232
3244
  async runRemoteExecution(run, registered) {
3233
3245
  if (run.status === "cancelling") {
3234
3246
  const error = {