Skip to content

Commit fb796f7

Browse files
committed
fixed the create checkpoint valid snapshot logic
1 parent ca4cee5 commit fb796f7

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

internal-packages/run-engine/src/engine/systems/checkpointSystem.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,20 @@ export class CheckpointSystem {
5353
return await this.$.runLock.lock([runId], 5_000, async () => {
5454
const snapshot = await getLatestExecutionSnapshot(prisma, runId);
5555

56-
if (snapshot.id !== snapshotId && snapshot.previousSnapshotId !== snapshotId) {
56+
const isValidSnapshot =
57+
// Case 1: The provided snapshotId matches the current snapshot
58+
snapshot.id === snapshotId ||
59+
// Case 2: The provided snapshotId matches the previous snapshot
60+
// AND we're in QUEUED_EXECUTING state (which is valid)
61+
(snapshot.previousSnapshotId === snapshotId &&
62+
snapshot.executionStatus === "QUEUED_EXECUTING");
63+
64+
if (!isValidSnapshot) {
65+
this.$.logger.error("Tried to createCheckpoint on an invalid snapshot", {
66+
snapshot,
67+
snapshotId,
68+
});
69+
5770
this.$.eventBus.emit("incomingCheckpointDiscarded", {
5871
time: new Date(),
5972
run: {

0 commit comments

Comments
 (0)