@@ -48,30 +48,29 @@ export class IdempotencyKeyConcern {
4848 } ) ;
4949
5050 // 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 } ,
5454 } ) ;
5555 } else {
56+ const associatedWaitpoint = existingRun . associatedWaitpoint ;
57+ const parentRunId = request . body . options ?. parentRunId ;
58+ const resumeParentOnCompletion = request . body . options ?. resumeParentOnCompletion ;
5659 //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 ) {
6261 await this . traceEventConcern . traceIdempotentRun (
6362 request ,
6463 {
6564 existingRun,
6665 idempotencyKey,
67- incomplete : existingRun . associatedWaitpoint . status === "PENDING" ,
68- isError : existingRun . associatedWaitpoint . outputIsError ,
66+ incomplete : associatedWaitpoint . status === "PENDING" ,
67+ isError : associatedWaitpoint . outputIsError ,
6968 } ,
7069 async ( event ) => {
7170 //block run with waitpoint
7271 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 ,
7574 spanIdToComplete : event . spanId ,
7675 batch : request . options ?. batchId
7776 ? {
0 commit comments