Skip to content

Commit a257452

Browse files
committed
large outputs now get unique keys again
1 parent 853a7ef commit a257452

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

packages/core/src/v3/idempotencyKeys.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ function injectScope(scope: "run" | "attempt" | "global"): string[] {
105105
}
106106
case "attempt": {
107107
if (taskContext?.ctx) {
108-
return [taskContext.ctx.attempt.id];
108+
return [taskContext.ctx.run.id, taskContext.ctx.attempt.number.toString()];
109109
}
110110
break;
111111
}
@@ -125,3 +125,17 @@ async function generateIdempotencyKey(keyMaterial: string[]) {
125125
.map((byte) => byte.toString(16).padStart(2, "0"))
126126
.join("");
127127
}
128+
129+
type AttemptKeyMaterial = {
130+
run: {
131+
id: string;
132+
};
133+
attempt: {
134+
number: number;
135+
};
136+
};
137+
138+
/** Creates a unique key for each attempt. */
139+
export function attemptKey(ctx: AttemptKeyMaterial): string {
140+
return `${ctx.run.id}-${ctx.attempt.number}`;
141+
}

packages/core/src/v3/workers/taskExecutor.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
} from "../errors.js";
1313
import {
1414
accessoryAttributes,
15+
attemptKey,
1516
flattenAttributes,
1617
lifecycleHooks,
1718
runMetadata,
@@ -235,7 +236,7 @@ export class TaskExecutor {
235236
const [exportError, finalOutput] = await tryCatch(
236237
conditionallyExportPacket(
237238
stringifiedOutput,
238-
`${execution.attempt.id}/output`,
239+
`${attemptKey(ctx)}/output`,
239240
this._tracer
240241
)
241242
);

0 commit comments

Comments
 (0)