@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.cjs
CHANGED
|
@@ -4030,6 +4030,15 @@ var WorkflowEngine = class {
|
|
|
4030
4030
|
/**
|
|
4031
4031
|
* Resume each run only if this instance can acquire its recovery lease — so when several
|
|
4032
4032
|
* replicas recover or poll at once, each run is picked up by exactly one of them.
|
|
4033
|
+
*
|
|
4034
|
+
* A run this instance cannot resume is SKIPPED, not allowed to abort the batch. The canonical
|
|
4035
|
+
* case is skew protection: mid-rolling-deploy a pod leases a run whose workflow it does not have
|
|
4036
|
+
* and `resume` throws by design — but the rest of the batch is runs it can drive perfectly well,
|
|
4037
|
+
* and every caller here is a recovery sweep. Letting the first such run end the loop means one
|
|
4038
|
+
* row stops recovery for the whole deployment, and (since the callers are pollers) sends the
|
|
4039
|
+
* rejection into a lifecycle hook. Skipping leaves the run locked only until its lease expires,
|
|
4040
|
+
* for a pod that does have the workflow — which is exactly what the skew-protection error asks
|
|
4041
|
+
* for. Same posture as `publishEvent`'s per-subscriber isolation.
|
|
4033
4042
|
*/
|
|
4034
4043
|
async resumeLeased(runs, nowMs = this.clock(), onLocked) {
|
|
4035
4044
|
if (this.draining) return [];
|
|
@@ -4037,8 +4046,12 @@ var WorkflowEngine = class {
|
|
|
4037
4046
|
for (const run of runs) {
|
|
4038
4047
|
const acquired = await this.store.tryLockRun(run.id, this.instanceId, nowMs + this.leaseMs, nowMs);
|
|
4039
4048
|
if (!acquired) continue;
|
|
4040
|
-
|
|
4041
|
-
|
|
4049
|
+
try {
|
|
4050
|
+
const settled = onLocked ? await onLocked(run) : void 0;
|
|
4051
|
+
results.push(settled ?? await this.resume(run.id));
|
|
4052
|
+
} catch (error2) {
|
|
4053
|
+
console.error(`[nestjs-durable] could not resume run ${run.id} (${run.workflow}@${run.workflowVersion}); leaving it for another instance:`, error2);
|
|
4054
|
+
}
|
|
4042
4055
|
}
|
|
4043
4056
|
return results;
|
|
4044
4057
|
}
|