@dudousxd/nestjs-durable-core 0.57.0 → 0.58.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
@@ -2477,7 +2477,7 @@ declare class WorkflowEngine {
2477
2477
  * inline — or null if the run is unknown. The dashboard "retry" goes through here so it can't block
2478
2478
  * the HTTP request on workflow execution.
2479
2479
  */
2480
- requeue(runId: string): Promise<RunResult | null>;
2480
+ requeue(runId: string, _seen?: Set<string>): Promise<RunResult | null>;
2481
2481
  /**
2482
2482
  * Explicitly re-dispatch every remote step of `runId` stuck `pending` — the OPERATOR escape hatch for
2483
2483
  * a run whose dispatched step job was LOST (worker crashed with no result, or a transport that dropped
package/dist/index.d.ts CHANGED
@@ -2477,7 +2477,7 @@ declare class WorkflowEngine {
2477
2477
  * inline — or null if the run is unknown. The dashboard "retry" goes through here so it can't block
2478
2478
  * the HTTP request on workflow execution.
2479
2479
  */
2480
- requeue(runId: string): Promise<RunResult | null>;
2480
+ requeue(runId: string, _seen?: Set<string>): Promise<RunResult | null>;
2481
2481
  /**
2482
2482
  * Explicitly re-dispatch every remote step of `runId` stuck `pending` — the OPERATOR escape hatch for
2483
2483
  * a run whose dispatched step job was LOST (worker crashed with no result, or a transport that dropped
package/dist/index.js CHANGED
@@ -2726,7 +2726,10 @@ var WorkflowEngine = class {
2726
2726
  * inline — or null if the run is unknown. The dashboard "retry" goes through here so it can't block
2727
2727
  * the HTTP request on workflow execution.
2728
2728
  */
2729
- async requeue(runId) {
2729
+ async requeue(runId, _seen) {
2730
+ const seen = _seen ?? /* @__PURE__ */ new Set();
2731
+ if (seen.has(runId)) return null;
2732
+ seen.add(runId);
2730
2733
  const run = await this.store.getRun(runId);
2731
2734
  if (!run) return null;
2732
2735
  if (run.status === "failed" || run.status === "dead") {
@@ -2750,12 +2753,28 @@ var WorkflowEngine = class {
2750
2753
  status: "running",
2751
2754
  output: void 0
2752
2755
  });
2756
+ const childId = cp.name.slice("signal:child:".length);
2757
+ const parked = [];
2758
+ for (; ; ) {
2759
+ const buffered = await this.store.takeBufferedSignal(`child:${childId}`);
2760
+ if (!buffered) break;
2761
+ parked.push(buffered.payload);
2762
+ }
2763
+ for (const payload of parked) await this.store.bufferSignal(`child:${childId}`, payload);
2764
+ const bufferedSuccess = parked.some((payload) => typeof payload === "object" && payload !== null && payload.ok === true);
2765
+ if (!bufferedSuccess) {
2766
+ const child = await this.store.getRun(childId);
2767
+ if (child && (child.status === "failed" || child.status === "dead")) {
2768
+ await this.requeue(childId, seen);
2769
+ }
2770
+ }
2753
2771
  }
2754
2772
  }
2755
2773
  }
2756
2774
  await this.store.releaseRunLock(runId);
2757
2775
  await this.store.updateRun(runId, {
2758
2776
  status: "pending",
2777
+ error: void 0,
2759
2778
  updatedAt: /* @__PURE__ */ new Date()
2760
2779
  });
2761
2780
  await this.runDispatcher.dispatch(runId);
@@ -3075,6 +3094,10 @@ var WorkflowEngine = class {
3075
3094
  */
3076
3095
  notifyParent(runId, completion) {
3077
3096
  void this.signal(`child:${runId}`, completion).catch(() => void 0);
3097
+ const at = runId.lastIndexOf("~retry~");
3098
+ if (at !== -1 && completion.ok) {
3099
+ void this.signal(`child:${runId.slice(0, at)}`, completion).catch(() => void 0);
3100
+ }
3078
3101
  }
3079
3102
  /**
3080
3103
  * Deferred child start shared by the in-process ctx host and the remote `startChild` command.