@@ -79,8 +79,8 @@ export class WaitpointSystem {
7979 } ;
8080 } ) : Promise < Waitpoint > {
8181 // 1. Complete the Waitpoint (if not completed)
82- let [ waitpointError , waitpoint ] = await tryCatch (
83- this . $ . prisma . waitpoint . update ( {
82+ const [ updateError , updateResult ] = await tryCatch (
83+ this . $ . prisma . waitpoint . updateMany ( {
8484 where : { id, status : "PENDING" } ,
8585 data : {
8686 status : "COMPLETED" ,
@@ -92,29 +92,32 @@ export class WaitpointSystem {
9292 } )
9393 ) ;
9494
95- if ( waitpointError ) {
96- if (
97- waitpointError instanceof Prisma . PrismaClientKnownRequestError &&
98- waitpointError . code === "P2025"
99- ) {
100- waitpoint = await this . $ . prisma . waitpoint . findFirst ( {
101- where : { id } ,
102- } ) ;
103- } else {
104- this . $ . logger . log ( "completeWaitpoint: error updating waitpoint:" , { waitpointError } ) ;
105- throw waitpointError ;
106- }
95+ if ( updateError ) {
96+ this . $ . logger . error ( "completeWaitpoint: error updating waitpoint:" , { updateError } ) ;
97+ throw updateError ;
10798 }
10899
100+ if ( updateResult . count === 0 ) {
101+ this . $ . logger . info (
102+ "completeWaitpoint: attempted to complete a waitpoint that is not PENDING" ,
103+ { waitpointId : id }
104+ ) ;
105+ }
106+
107+ const waitpoint = await this . $ . prisma . waitpoint . findFirst ( {
108+ where : { id } ,
109+ } ) ;
110+
109111 if ( ! waitpoint ) {
110- throw new Error ( `Waitpoint ${ id } not found` ) ;
112+ this . $ . logger . error ( "completeWaitpoint: waitpoint not found" , { waitpointId : id } ) ;
113+ throw new Error ( "Waitpoint not found" ) ;
111114 }
112115
113116 if ( waitpoint . status !== "COMPLETED" ) {
114117 this . $ . logger . error ( `completeWaitpoint: waitpoint is not completed` , {
115118 waitpointId : id ,
116119 } ) ;
117- throw new Error ( ` Waitpoint ${ id } is not completed` ) ;
120+ throw new Error ( " Waitpoint not completed" ) ;
118121 }
119122
120123 // 2. Find the TaskRuns blocked by this waitpoint
0 commit comments