@dudousxd/nestjs-durable-core 0.49.0 → 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;
@@ -2960,10 +2962,21 @@ var WorkflowEngine = class {
2960
2962
  ...this.knownGroups(extra),
2961
2963
  ...await this.pool.listWorkerGroups()
2962
2964
  ]);
2965
+ const workflowTokens = /* @__PURE__ */ new Set();
2966
+ for (const def of this.workflows.values()) {
2967
+ workflowTokens.add(sanitizeQueueToken(def.name));
2968
+ if (def.remote?.group) workflowTokens.add(def.remote.group);
2969
+ }
2963
2970
  const out = [];
2964
2971
  for (const group of groups) {
2965
2972
  const health = await this.pool.groupHealth(group);
2966
- if (health) out.push(health);
2973
+ if (!health) continue;
2974
+ const at = group.lastIndexOf("@");
2975
+ const baseToken = at === -1 ? group : group.slice(0, at);
2976
+ out.push({
2977
+ ...health,
2978
+ kind: workflowTokens.has(baseToken) ? "workflow" : "step"
2979
+ });
2967
2980
  }
2968
2981
  return out;
2969
2982
  }
@@ -3204,7 +3217,7 @@ var WorkflowEngine = class {
3204
3217
  }
3205
3218
  await this.store.updateRun(run.id, {
3206
3219
  status: "suspended",
3207
- wakeAt: outcome.wakeAt,
3220
+ wakeAt: this.reconcileWakeAt(outcome.wakeAt),
3208
3221
  updatedAt
3209
3222
  });
3210
3223
  this.emit({
@@ -3218,6 +3231,16 @@ var WorkflowEngine = class {
3218
3231
  status: "suspended"
3219
3232
  };
3220
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
+ }
3221
3244
  async runRemoteExecution(run, registered) {
3222
3245
  if (run.status === "cancelling") {
3223
3246
  const error = {