@dudousxd/nestjs-durable-core 0.69.0 → 0.69.1
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 +15 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +15 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -3692,6 +3692,15 @@ declare class WorkflowEngine {
|
|
|
3692
3692
|
/**
|
|
3693
3693
|
* Resume each run only if this instance can acquire its recovery lease — so when several
|
|
3694
3694
|
* replicas recover or poll at once, each run is picked up by exactly one of them.
|
|
3695
|
+
*
|
|
3696
|
+
* A run this instance cannot resume is SKIPPED, not allowed to abort the batch. The canonical
|
|
3697
|
+
* case is skew protection: mid-rolling-deploy a pod leases a run whose workflow it does not have
|
|
3698
|
+
* and `resume` throws by design — but the rest of the batch is runs it can drive perfectly well,
|
|
3699
|
+
* and every caller here is a recovery sweep. Letting the first such run end the loop means one
|
|
3700
|
+
* row stops recovery for the whole deployment, and (since the callers are pollers) sends the
|
|
3701
|
+
* rejection into a lifecycle hook. Skipping leaves the run locked only until its lease expires,
|
|
3702
|
+
* for a pod that does have the workflow — which is exactly what the skew-protection error asks
|
|
3703
|
+
* for. Same posture as `publishEvent`'s per-subscriber isolation.
|
|
3695
3704
|
*/
|
|
3696
3705
|
private resumeLeased;
|
|
3697
3706
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -3692,6 +3692,15 @@ declare class WorkflowEngine {
|
|
|
3692
3692
|
/**
|
|
3693
3693
|
* Resume each run only if this instance can acquire its recovery lease — so when several
|
|
3694
3694
|
* replicas recover or poll at once, each run is picked up by exactly one of them.
|
|
3695
|
+
*
|
|
3696
|
+
* A run this instance cannot resume is SKIPPED, not allowed to abort the batch. The canonical
|
|
3697
|
+
* case is skew protection: mid-rolling-deploy a pod leases a run whose workflow it does not have
|
|
3698
|
+
* and `resume` throws by design — but the rest of the batch is runs it can drive perfectly well,
|
|
3699
|
+
* and every caller here is a recovery sweep. Letting the first such run end the loop means one
|
|
3700
|
+
* row stops recovery for the whole deployment, and (since the callers are pollers) sends the
|
|
3701
|
+
* rejection into a lifecycle hook. Skipping leaves the run locked only until its lease expires,
|
|
3702
|
+
* for a pod that does have the workflow — which is exactly what the skew-protection error asks
|
|
3703
|
+
* for. Same posture as `publishEvent`'s per-subscriber isolation.
|
|
3695
3704
|
*/
|
|
3696
3705
|
private resumeLeased;
|
|
3697
3706
|
/**
|
package/dist/index.js
CHANGED
|
@@ -3889,6 +3889,15 @@ var WorkflowEngine = class {
|
|
|
3889
3889
|
/**
|
|
3890
3890
|
* Resume each run only if this instance can acquire its recovery lease — so when several
|
|
3891
3891
|
* replicas recover or poll at once, each run is picked up by exactly one of them.
|
|
3892
|
+
*
|
|
3893
|
+
* A run this instance cannot resume is SKIPPED, not allowed to abort the batch. The canonical
|
|
3894
|
+
* case is skew protection: mid-rolling-deploy a pod leases a run whose workflow it does not have
|
|
3895
|
+
* and `resume` throws by design — but the rest of the batch is runs it can drive perfectly well,
|
|
3896
|
+
* and every caller here is a recovery sweep. Letting the first such run end the loop means one
|
|
3897
|
+
* row stops recovery for the whole deployment, and (since the callers are pollers) sends the
|
|
3898
|
+
* rejection into a lifecycle hook. Skipping leaves the run locked only until its lease expires,
|
|
3899
|
+
* for a pod that does have the workflow — which is exactly what the skew-protection error asks
|
|
3900
|
+
* for. Same posture as `publishEvent`'s per-subscriber isolation.
|
|
3892
3901
|
*/
|
|
3893
3902
|
async resumeLeased(runs, nowMs = this.clock(), onLocked) {
|
|
3894
3903
|
if (this.draining) return [];
|
|
@@ -3896,8 +3905,12 @@ var WorkflowEngine = class {
|
|
|
3896
3905
|
for (const run of runs) {
|
|
3897
3906
|
const acquired = await this.store.tryLockRun(run.id, this.instanceId, nowMs + this.leaseMs, nowMs);
|
|
3898
3907
|
if (!acquired) continue;
|
|
3899
|
-
|
|
3900
|
-
|
|
3908
|
+
try {
|
|
3909
|
+
const settled = onLocked ? await onLocked(run) : void 0;
|
|
3910
|
+
results.push(settled ?? await this.resume(run.id));
|
|
3911
|
+
} catch (error2) {
|
|
3912
|
+
console.error(`[nestjs-durable] could not resume run ${run.id} (${run.workflow}@${run.workflowVersion}); leaving it for another instance:`, error2);
|
|
3913
|
+
}
|
|
3901
3914
|
}
|
|
3902
3915
|
return results;
|
|
3903
3916
|
}
|