File tree Expand file tree Collapse file tree 5 files changed +31
-2
lines changed Expand file tree Collapse file tree 5 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -1301,4 +1301,16 @@ export function runIntegrationTests(codec?: PayloadCodec): void {
1301
1301
// Verify only one timer was scheduled
1302
1302
t . is ( history . events . filter ( ( { timerStartedEventAttributes } ) => timerStartedEventAttributes != null ) . length , 1 ) ;
1303
1303
} ) ;
1304
+
1305
+ test ( 'Query does not cause condition to be triggered' , async ( t ) => {
1306
+ const { client } = t . context ;
1307
+ const workflowId = uuid4 ( ) ;
1308
+ const handle = await client . start ( workflows . queryAndCondition , {
1309
+ taskQueue : 'test' ,
1310
+ workflowId,
1311
+ } ) ;
1312
+ await handle . query ( workflows . mutateWorkflowStateQuery ) ;
1313
+ // Worker did not crash
1314
+ t . pass ( ) ;
1315
+ } ) ;
1304
1316
}
Original file line number Diff line number Diff line change @@ -56,6 +56,7 @@ export * from './patched-top-level';
56
56
export * from './promise-all' ;
57
57
export * from './promise-race' ;
58
58
export * from './promise-then-promise' ;
59
+ export * from './query-and-condition' ;
59
60
export * from './race' ;
60
61
export * from './random' ;
61
62
export * from './reject-promise' ;
Original file line number Diff line number Diff line change
1
+ import * as wf from '@temporalio/workflow' ;
2
+
3
+ export const mutateWorkflowStateQuery = wf . defineQuery < void > ( 'mutateWorkflowState' ) ;
4
+
5
+ export async function queryAndCondition ( ) : Promise < void > {
6
+ let mutated = false ;
7
+ // Not a valid query, used to verify that condition isn't triggered for query jobs
8
+ wf . setHandler ( mutateWorkflowStateQuery , ( ) => void ( mutated = true ) ) ;
9
+ await wf . condition ( ( ) => mutated ) ;
10
+ }
Original file line number Diff line number Diff line change @@ -397,7 +397,10 @@ export class VMWorkflow implements Workflow {
397
397
coresdk . workflow_activation . WorkflowActivation . fromObject ( { ...activation , jobs } ) ,
398
398
batchIndex ++
399
399
) ;
400
- await this . tryUnblockConditions ( ) ;
400
+ // Only trigger conditions for non-query jobs
401
+ if ( ! jobs [ 0 ] . queryWorkflow ) {
402
+ await this . tryUnblockConditions ( ) ;
403
+ }
401
404
}
402
405
const completion = this . workflowModule . concludeActivation ( ) ;
403
406
// Give unhandledRejection handler a chance to be triggered.
Original file line number Diff line number Diff line change @@ -222,7 +222,10 @@ export function activate(activation: coresdk.workflow_activation.WorkflowActivat
222
222
return ;
223
223
}
224
224
state . activator [ job . variant ] ( variant as any /* TS can't infer this type */ ) ;
225
- tryUnblockConditions ( ) ;
225
+ // Only trigger conditions for non-query jobs
226
+ if ( ! job . queryWorkflow ) {
227
+ tryUnblockConditions ( ) ;
228
+ }
226
229
}
227
230
} ) ;
228
231
intercept ( {
You can’t perform that action at this time.
0 commit comments