@@ -48,30 +48,29 @@ export class IdempotencyKeyConcern {
48
48
} ) ;
49
49
50
50
// Update the existing run to remove the idempotency key
51
- await this . prisma . taskRun . update ( {
52
- where : { id : existingRun . id } ,
53
- data : { idempotencyKey : null } ,
51
+ await this . prisma . taskRun . updateMany ( {
52
+ where : { id : existingRun . id , idempotencyKey } ,
53
+ data : { idempotencyKey : null , idempotencyKeyExpiresAt : null } ,
54
54
} ) ;
55
55
} else {
56
+ const associatedWaitpoint = existingRun . associatedWaitpoint ;
57
+ const parentRunId = request . body . options ?. parentRunId ;
58
+ const resumeParentOnCompletion = request . body . options ?. resumeParentOnCompletion ;
56
59
//We're using `andWait` so we need to block the parent run with a waitpoint
57
- if (
58
- existingRun . associatedWaitpoint &&
59
- request . body . options ?. resumeParentOnCompletion &&
60
- request . body . options ?. parentRunId
61
- ) {
60
+ if ( associatedWaitpoint && resumeParentOnCompletion && parentRunId ) {
62
61
await this . traceEventConcern . traceIdempotentRun (
63
62
request ,
64
63
{
65
64
existingRun,
66
65
idempotencyKey,
67
- incomplete : existingRun . associatedWaitpoint . status === "PENDING" ,
68
- isError : existingRun . associatedWaitpoint . outputIsError ,
66
+ incomplete : associatedWaitpoint . status === "PENDING" ,
67
+ isError : associatedWaitpoint . outputIsError ,
69
68
} ,
70
69
async ( event ) => {
71
70
//block run with waitpoint
72
71
await this . engine . blockRunWithWaitpoint ( {
73
- runId : RunId . fromFriendlyId ( request . body . options ! . parentRunId ! ) ,
74
- waitpoints : existingRun . associatedWaitpoint ! . id ,
72
+ runId : RunId . fromFriendlyId ( parentRunId ) ,
73
+ waitpoints : associatedWaitpoint . id ,
75
74
spanIdToComplete : event . spanId ,
76
75
batch : request . options ?. batchId
77
76
? {
0 commit comments