Skip to content

Commit 7038f4c

Browse files
committed
Better batch support in the run engine
1 parent bf6946a commit 7038f4c

File tree

5 files changed

+350
-116
lines changed

5 files changed

+350
-116
lines changed

internal-packages/run-engine/src/engine/executionSnapshots.ts

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -35,29 +35,30 @@ export async function getLatestExecutionSnapshot(
3535
...snapshot,
3636
friendlyId: SnapshotId.toFriendlyId(snapshot.id),
3737
runFriendlyId: RunId.toFriendlyId(snapshot.runId),
38-
completedWaitpoints: snapshot.completedWaitpoints.map(
39-
(w) =>
40-
({
41-
id: w.id,
42-
friendlyId: w.friendlyId,
43-
type: w.type,
44-
completedAt: w.completedAt ?? new Date(),
45-
idempotencyKey:
46-
w.userProvidedIdempotencyKey && !w.inactiveIdempotencyKey
47-
? w.idempotencyKey
48-
: undefined,
49-
completedByTaskRun: w.completedByTaskRunId
50-
? {
51-
id: w.completedByTaskRunId,
52-
friendlyId: RunId.toFriendlyId(w.completedByTaskRunId),
53-
}
54-
: undefined,
55-
completedAfter: w.completedAfter ?? undefined,
56-
output: w.output ?? undefined,
57-
outputType: w.outputType,
58-
outputIsError: w.outputIsError,
59-
}) satisfies CompletedWaitpoint
60-
),
38+
completedWaitpoints: snapshot.completedWaitpoints.map((w) => {
39+
const index = snapshot.completedWaitpointOrder.findIndex((s) => s === w.id);
40+
41+
return {
42+
id: w.id,
43+
index: index === -1 ? undefined : index,
44+
friendlyId: w.friendlyId,
45+
type: w.type,
46+
completedAt: w.completedAt ?? new Date(),
47+
idempotencyKey:
48+
w.userProvidedIdempotencyKey && !w.inactiveIdempotencyKey ? w.idempotencyKey : undefined,
49+
completedByTaskRun: w.completedByTaskRunId
50+
? {
51+
id: w.completedByTaskRunId,
52+
friendlyId: RunId.toFriendlyId(w.completedByTaskRunId),
53+
}
54+
: undefined,
55+
completedAfter: w.completedAfter ?? undefined,
56+
completedByBatchId: w.completedByBatchId ?? undefined,
57+
output: w.output ?? undefined,
58+
outputType: w.outputType,
59+
outputIsError: w.outputIsError,
60+
} satisfies CompletedWaitpoint;
61+
}),
6162
};
6263
}
6364

0 commit comments

Comments
 (0)