@dudousxd/nestjs-durable-core 0.55.1 → 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
@@ -1204,17 +1204,6 @@ var TransportPool = class {
1204
1204
  }
1205
1205
  return void 0;
1206
1206
  }
1207
- /**
1208
- * Propagate the engine's `namespace` to every transport that partitions by it — so the same
1209
- * namespace that scopes the store also scopes each transport's queues/keys. A transport that
1210
- * doesn't partition (no `useNamespace`) is skipped. Idempotent; a transport given an explicit
1211
- * namespace at construction ignores this (see {@link Transport.useNamespace}).
1212
- */
1213
- useNamespace(namespace) {
1214
- for (const { transport } of this.transports) {
1215
- transport.useNamespace?.(namespace);
1216
- }
1217
- }
1218
1207
  /** Pinned `preferId` first, then the rest (failover order). */
1219
1208
  ordered(preferId) {
1220
1209
  if (!preferId) return this.transports;
@@ -1595,6 +1584,22 @@ function createWorkflowCtx(host, runId, compensations, workflow = "", searchAttr
1595
1584
  runId,
1596
1585
  seq: current
1597
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
+ }
1598
1603
  if (!await store.getRun(id)) host.startChild(workflowName(workflow2), input, id, priority);
1599
1604
  if (!existing) {
1600
1605
  await writeCheckpoint(instantCheckpoint({
@@ -2036,9 +2041,6 @@ var WorkflowEngine = class {
2036
2041
  this.admission.onFreed?.((queue) => this.wakeQueueWaiters(queue));
2037
2042
  this.instanceId = deps.instanceId ?? globalThis.crypto.randomUUID();
2038
2043
  this.namespace = deps.namespace;
2039
- if (this.namespace !== void 0) {
2040
- this.pool.useNamespace(this.namespace);
2041
- }
2042
2044
  this.leaseMs = deps.leaseMs ?? 3e4;
2043
2045
  this.maxRecoveryAttempts = deps.maxRecoveryAttempts;
2044
2046
  this.remoteAdvanceSilenceMs = deps.remoteAdvanceSilenceMs;
@@ -2818,6 +2820,30 @@ var WorkflowEngine = class {
2818
2820
  async requeue(runId) {
2819
2821
  const run = await this.store.getRun(runId);
2820
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
+ }
2821
2847
  await this.store.releaseRunLock(runId);
2822
2848
  await this.store.updateRun(runId, {
2823
2849
  status: "pending",