@dudousxd/nestjs-durable-core 0.56.0 → 0.57.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.cjs CHANGED
@@ -1584,6 +1584,22 @@ function createWorkflowCtx(host, runId, compensations, workflow = "", searchAttr
1584
1584
  runId,
1585
1585
  seq: current
1586
1586
  });
1587
+ const buffered = await store.takeBufferedSignal(`child:${id}`);
1588
+ if (buffered) {
1589
+ await store.removeSignalWaiter({
1590
+ token: `child:${id}`,
1591
+ runId,
1592
+ seq: current
1593
+ });
1594
+ await writeCheckpoint(instantCheckpoint({
1595
+ runId,
1596
+ seq: current,
1597
+ name: `signal:child:${id}`,
1598
+ kind: "signal",
1599
+ output: buffered.payload
1600
+ }));
1601
+ return unwrapCompletion(buffered.payload, `child "${id}"`);
1602
+ }
1587
1603
  if (!await store.getRun(id)) host.startChild(workflowName(workflow2), input, id, priority);
1588
1604
  if (!existing) {
1589
1605
  await writeCheckpoint(instantCheckpoint({
@@ -2804,6 +2820,30 @@ var WorkflowEngine = class {
2804
2820
  async requeue(runId) {
2805
2821
  const run = await this.store.getRun(runId);
2806
2822
  if (!run) return null;
2823
+ if (run.status === "failed" || run.status === "dead") {
2824
+ const isFailureCompletion = /* @__PURE__ */ __name((v) => typeof v === "object" && v !== null && v.ok === false, "isFailureCompletion");
2825
+ for (const cp of await this.store.listCheckpoints(runId)) {
2826
+ if (cp.status === "failed") {
2827
+ await this.store.saveCheckpoint({
2828
+ ...cp,
2829
+ attempts: 0,
2830
+ wakeAt: this.clock(),
2831
+ ...cp.error ? {
2832
+ error: {
2833
+ ...cp.error,
2834
+ retryable: true
2835
+ }
2836
+ } : {}
2837
+ });
2838
+ } else if (cp.kind === "signal" && cp.name.startsWith("signal:child:") && cp.status === "completed" && isFailureCompletion(cp.output)) {
2839
+ await this.store.saveCheckpoint({
2840
+ ...cp,
2841
+ status: "running",
2842
+ output: void 0
2843
+ });
2844
+ }
2845
+ }
2846
+ }
2807
2847
  await this.store.releaseRunLock(runId);
2808
2848
  await this.store.updateRun(runId, {
2809
2849
  status: "pending",