Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/engine/src/graph/runner/holds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ export function combineHolds(parts: readonly RunHolds[]): RunHolds {
try {
await part.resuming(row, run, at);
} catch (error) {
const status = run.end?.status ?? "failed";
await Promise.allSettled(
parts.slice(0, i).map((done) => done.ended(row.id, status)),
parts.slice(0, i).map((done) => done.notContinuing(row.id)),
);
throw error;
}
Expand Down
10 changes: 6 additions & 4 deletions packages/engine/src/services/holds.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,15 @@ describe("serviceHolds", () => {
});

describe("combineHolds", () => {
test("given a part that refuses the resume, then the parts before it let go again", async () => {
test("given an interrupted run, when a part refuses the resume, then the parts before it let go of what they took again", async () => {
const calls: string[] = [];
const part = (name: string, refuses = false): RunHolds => ({
ended: async (_runId, status) => {
calls.push(`${name} ended ${status}`);
},
notContinuing: async () => {},
notContinuing: async () => {
calls.push(`${name} does not continue`);
},
resuming: async () => {
calls.push(`${name} resuming`);
if (refuses) throw new Error(`${name} refuses`);
Expand All @@ -185,7 +187,7 @@ describe("combineHolds", () => {
const holds = combineHolds([part("leases"), part("services", true)]);

await expect(
holds.resuming({ id: "run-1" } as RunRow, runState("stopped"), {
holds.resuming({ id: "run-1" } as RunRow, runState("interrupted"), {
nodeId: "test",
scope: null,
}),
Expand All @@ -194,7 +196,7 @@ describe("combineHolds", () => {
expect(calls).toEqual([
"leases resuming",
"services resuming",
"leases ended stopped",
"leases does not continue",
]);
});
});
Loading