@dudousxd/nestjs-durable-core 0.76.0 → 0.76.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 +26 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3867,6 +3867,12 @@ var WorkflowEngine = class {
|
|
|
3867
3867
|
* {@link redriveSettledSteps}).
|
|
3868
3868
|
*/
|
|
3869
3869
|
awaitedRemoteSteps = /* @__PURE__ */ new Map();
|
|
3870
|
+
/**
|
|
3871
|
+
* When THIS instance settled a remote step from its result, by `runId:seq`. That result's resume
|
|
3872
|
+
* runs here, and `execute` lets it into a lease this instance holds, so its wake is never the
|
|
3873
|
+
* dropped one {@link redriveSettledSteps} recovers. Pruned by age (see {@link noteSettledHere}).
|
|
3874
|
+
*/
|
|
3875
|
+
settledHere = /* @__PURE__ */ new Map();
|
|
3870
3876
|
/** Flow-control admission backend for remote steps (see {@link registerQueue}). */
|
|
3871
3877
|
admission;
|
|
3872
3878
|
/** Runs on THIS instance blocked on admission, by queue — woken early on a freed-slot signal. */
|
|
@@ -5294,6 +5300,16 @@ var WorkflowEngine = class {
|
|
|
5294
5300
|
for (const seq of seqs) {
|
|
5295
5301
|
const cp = await this.store.getCheckpoint(runId, seq);
|
|
5296
5302
|
if (cp && (cp.status === "completed" || cp.status === "failed")) {
|
|
5303
|
+
if (this.settledHere.has(`${runId}:${seq}`)) return;
|
|
5304
|
+
const nowMs = this.clock();
|
|
5305
|
+
if (!await this.store.tryLockRun(runId, this.instanceId, nowMs + this.leaseMs, nowMs)) {
|
|
5306
|
+
return;
|
|
5307
|
+
}
|
|
5308
|
+
const run = await this.store.getRun(runId);
|
|
5309
|
+
if (run?.status !== "suspended") {
|
|
5310
|
+
await this.store.releaseRunLock(runId);
|
|
5311
|
+
return;
|
|
5312
|
+
}
|
|
5297
5313
|
await this.resumeImplicit(runId);
|
|
5298
5314
|
return;
|
|
5299
5315
|
}
|
|
@@ -7390,6 +7406,15 @@ var WorkflowEngine = class {
|
|
|
7390
7406
|
this.awaitedRemoteSteps.get(runId)?.add(seq);
|
|
7391
7407
|
throw new WorkflowSuspended();
|
|
7392
7408
|
}
|
|
7409
|
+
/** Remember a step settled here, forgetting entries older than a lease so the map stays small. */
|
|
7410
|
+
noteSettledHere(key) {
|
|
7411
|
+
const now = this.clock();
|
|
7412
|
+
this.settledHere.set(key, now);
|
|
7413
|
+
if (this.settledHere.size < 1024) return;
|
|
7414
|
+
for (const [k, at] of this.settledHere) {
|
|
7415
|
+
if (now - at > this.leaseMs) this.settledHere.delete(k);
|
|
7416
|
+
}
|
|
7417
|
+
}
|
|
7393
7418
|
/** {@link StateStore.saveCheckpointIfPending}, or a plain save on a store without it. */
|
|
7394
7419
|
async savePendingCheckpoint(checkpoint) {
|
|
7395
7420
|
if (this.store.saveCheckpointIfPending) return this.store.saveCheckpointIfPending(checkpoint);
|
|
@@ -7436,6 +7461,7 @@ var WorkflowEngine = class {
|
|
|
7436
7461
|
finishedAt
|
|
7437
7462
|
});
|
|
7438
7463
|
if (!claimed) return;
|
|
7464
|
+
this.noteSettledHere(`${result.runId}:${result.seq}`);
|
|
7439
7465
|
this.emit({
|
|
7440
7466
|
type: result.status === "completed" ? "step.completed" : "step.failed",
|
|
7441
7467
|
runId: result.runId,
|