@dudousxd/nestjs-durable-core 0.106.0 → 0.106.2
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 +21 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +21 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -7310,6 +7310,10 @@ function createWorkflowCtx(host, runId, compensations, workflow = "", searchAttr
|
|
|
7310
7310
|
__name(createWorkflowCtx, "createWorkflowCtx");
|
|
7311
7311
|
|
|
7312
7312
|
// src/engine.ts
|
|
7313
|
+
function isRequeuedStepFailure(cp) {
|
|
7314
|
+
return cp.status === "failed" && cp.attempts === 0 && cp.seq >= 0 && (cp.kind === "local" || cp.kind === "remote");
|
|
7315
|
+
}
|
|
7316
|
+
__name(isRequeuedStepFailure, "isRequeuedStepFailure");
|
|
7313
7317
|
function mergeTags(staticTags, runTags) {
|
|
7314
7318
|
if (!staticTags?.length && !runTags?.length) return void 0;
|
|
7315
7319
|
return [
|
|
@@ -13176,6 +13180,20 @@ var WorkflowEngine = class _WorkflowEngine {
|
|
|
13176
13180
|
];
|
|
13177
13181
|
}
|
|
13178
13182
|
/**
|
|
13183
|
+
* Whether a streamed step event comes from the turn its run awaits. A dispatched turn that went
|
|
13184
|
+
* quiet past the silence window is dispatched again, but its first worker may still be replaying it
|
|
13185
|
+
* and streaming its steps; written unchecked, those would put a stale turn's output under the live
|
|
13186
|
+
* turn's checkpoint. An event without a `taskId` (a worker from before the field) is kept.
|
|
13187
|
+
*/
|
|
13188
|
+
async stepEventFromAwaitedTurn(event) {
|
|
13189
|
+
if (event.taskId === void 0) return true;
|
|
13190
|
+
const run = await this.store.getRun(event.runId);
|
|
13191
|
+
if (!run) return false;
|
|
13192
|
+
return awaitsDecision(run, {
|
|
13193
|
+
taskId: event.taskId
|
|
13194
|
+
});
|
|
13195
|
+
}
|
|
13196
|
+
/**
|
|
13179
13197
|
* Persist a streamed local-step lifecycle event from a remote workflow worker (see
|
|
13180
13198
|
* {@link WorkflowStepEvent}). A Python `@workflow` runs its `ctx.step`s inline over one turn that
|
|
13181
13199
|
* can last minutes; the worker streams each step's start/finish so the engine checkpoints it LIVE —
|
|
@@ -13185,6 +13203,7 @@ var WorkflowEngine = class _WorkflowEngine {
|
|
|
13185
13203
|
* idempotently, so this is purely additive observability and never changes the run's outcome.
|
|
13186
13204
|
*/
|
|
13187
13205
|
async persistStepEvent(event) {
|
|
13206
|
+
if (!await this.stepEventFromAwaitedTurn(event)) return;
|
|
13188
13207
|
const startedAt = new Date(event.startedAt);
|
|
13189
13208
|
if (event.phase === "running") {
|
|
13190
13209
|
await this.store.saveCheckpoint(stepCheckpoint({
|
|
@@ -14499,6 +14518,7 @@ ${run.workflowVersion}`;
|
|
|
14499
14518
|
};
|
|
14500
14519
|
const events = [];
|
|
14501
14520
|
for (const cp of checkpoints) {
|
|
14521
|
+
if (isRequeuedStepFailure(cp)) continue;
|
|
14502
14522
|
if (cp.status === "completed" || cp.status === "failed") {
|
|
14503
14523
|
if (cp.seq >= HANDOFF_SEQ_BASE) continue;
|
|
14504
14524
|
if (isAnyCheckpoint(cp)) {
|
|
@@ -14583,7 +14603,7 @@ ${run.workflowVersion}`;
|
|
|
14583
14603
|
});
|
|
14584
14604
|
} else if (cmd.kind === "call") {
|
|
14585
14605
|
const existing = await this.store.getCheckpoint(run.id, cmd.seq);
|
|
14586
|
-
if (existing) {
|
|
14606
|
+
if (existing && !isRequeuedStepFailure(existing)) {
|
|
14587
14607
|
const policed = redriveLost && cmd.policy !== void 0 ? await this.applyCallPolicy(run, cmd, existing) : null;
|
|
14588
14608
|
const leaseAt = policed !== null ? policed : redriveLost ? await this.redriveLostCall(run, existing) : void 0;
|
|
14589
14609
|
if (leaseAt != null) wakeAt = wakeAt == null ? leaseAt : Math.min(wakeAt, leaseAt);
|