@@ -79,8 +79,8 @@ export class WaitpointSystem {
79
79
} ;
80
80
} ) : Promise < Waitpoint > {
81
81
// 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 ( {
84
84
where : { id, status : "PENDING" } ,
85
85
data : {
86
86
status : "COMPLETED" ,
@@ -92,29 +92,32 @@ export class WaitpointSystem {
92
92
} )
93
93
) ;
94
94
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 ;
107
98
}
108
99
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
+
109
111
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" ) ;
111
114
}
112
115
113
116
if ( waitpoint . status !== "COMPLETED" ) {
114
117
this . $ . logger . error ( `completeWaitpoint: waitpoint is not completed` , {
115
118
waitpointId : id ,
116
119
} ) ;
117
- throw new Error ( ` Waitpoint ${ id } is not completed` ) ;
120
+ throw new Error ( " Waitpoint not completed" ) ;
118
121
}
119
122
120
123
// 2. Find the TaskRuns blocked by this waitpoint
0 commit comments