@@ -20,6 +20,12 @@ import { VMWorkflow, VMWorkflowCreator } from '@temporalio/worker/lib/workflow/v
20
20
import { SdkFlag , SdkFlags } from '@temporalio/workflow/lib/flags' ;
21
21
import { ReusableVMWorkflow , ReusableVMWorkflowCreator } from '@temporalio/worker/lib/workflow/reusable-vm' ;
22
22
import { parseWorkflowCode } from '@temporalio/worker/lib/worker' ;
23
+ import {
24
+ ENHANCED_STACK_TRACE_RESERVED_PREFIX ,
25
+ reservedPrefixes ,
26
+ STACK_TRACE_RESERVED_PREFIX ,
27
+ TEMPORAL_RESERVED_PREFIX ,
28
+ } from '@temporalio/common/lib/reserved' ;
23
29
import * as activityFunctions from './activities' ;
24
30
import { cleanStackTrace , REUSE_V8_CONTEXT , u8 } from './helpers' ;
25
31
import { ProcessedSignal } from './workflows' ;
@@ -2528,3 +2534,83 @@ test('Signals/Updates/Activities/Timers - Trace promises completion order - 1.11
2528
2534
) ;
2529
2535
}
2530
2536
} ) ;
2537
+
2538
+ test ( 'Default query handler fail activations with reserved names - workflowWithDefaultHandlers' , async ( t ) => {
2539
+ const { workflowType } = t . context ;
2540
+
2541
+ await activate ( t , makeActivation ( undefined , makeInitializeWorkflowJob ( workflowType ) ) ) ;
2542
+
2543
+ for ( const prefix of reservedPrefixes ) {
2544
+ const completion = await activate ( t , makeActivation ( undefined , makeQueryWorkflowJob ( '1' , prefix + '_query' ) ) ) ;
2545
+
2546
+ compareCompletion ( t , completion , {
2547
+ failed : {
2548
+ failure : {
2549
+ ...completion . failed ?. failure ,
2550
+ // We only care about the error message.
2551
+ message : `Cannot register query name: '${ prefix } _query', with reserved prefix: '${ prefix } '` ,
2552
+ } ,
2553
+ } ,
2554
+ } ) ;
2555
+ }
2556
+ } ) ;
2557
+
2558
+ test ( 'Default signal handler fail activations with temporal prefix - workflowWithDefaultHandlers' , async ( t ) => {
2559
+ const { workflowType } = t . context ;
2560
+
2561
+ await activate ( t , makeActivation ( undefined , makeInitializeWorkflowJob ( workflowType ) ) ) ;
2562
+ const signalName = TEMPORAL_RESERVED_PREFIX + '_signal' ;
2563
+ const job = makeSignalWorkflowJob ( signalName , [ ] ) ;
2564
+
2565
+ const completion = await activate ( t , makeActivation ( undefined , job ) ) ;
2566
+
2567
+ compareCompletion ( t , completion , {
2568
+ failed : {
2569
+ failure : {
2570
+ ...completion . failed ?. failure ,
2571
+ // We only care about the error message.
2572
+ message : `Cannot register signal name: '${ signalName } ', with reserved prefix: '${ TEMPORAL_RESERVED_PREFIX } '` ,
2573
+ } ,
2574
+ } ,
2575
+ } ) ;
2576
+ } ) ;
2577
+
2578
+ test ( 'Default signal handler fail activations with stack trace prefix - workflowWithDefaultHandlers' , async ( t ) => {
2579
+ const { workflowType } = t . context ;
2580
+
2581
+ await activate ( t , makeActivation ( undefined , makeInitializeWorkflowJob ( workflowType ) ) ) ;
2582
+ const signalName = STACK_TRACE_RESERVED_PREFIX + '_signal' ;
2583
+ const job = makeSignalWorkflowJob ( signalName , [ ] ) ;
2584
+
2585
+ const completion = await activate ( t , makeActivation ( undefined , job ) ) ;
2586
+
2587
+ compareCompletion ( t , completion , {
2588
+ failed : {
2589
+ failure : {
2590
+ ...completion . failed ?. failure ,
2591
+ // We only care about the error message.
2592
+ message : `Cannot register signal name: '${ signalName } ', with reserved prefix: '${ STACK_TRACE_RESERVED_PREFIX } '` ,
2593
+ } ,
2594
+ } ,
2595
+ } ) ;
2596
+ } ) ;
2597
+
2598
+ test ( 'Default signal handler fail activations with enhanced stack trace prefix - workflowWithDefaultHandlers' , async ( t ) => {
2599
+ const { workflowType } = t . context ;
2600
+
2601
+ await activate ( t , makeActivation ( undefined , makeInitializeWorkflowJob ( workflowType ) ) ) ;
2602
+ const signalName = ENHANCED_STACK_TRACE_RESERVED_PREFIX + '_signal' ;
2603
+ const job = makeSignalWorkflowJob ( signalName , [ ] ) ;
2604
+
2605
+ const completion = await activate ( t , makeActivation ( undefined , job ) ) ;
2606
+
2607
+ compareCompletion ( t , completion , {
2608
+ failed : {
2609
+ failure : {
2610
+ ...completion . failed ?. failure ,
2611
+ // We only care about the error message.
2612
+ message : `Cannot register signal name: '${ signalName } ', with reserved prefix: '${ ENHANCED_STACK_TRACE_RESERVED_PREFIX } '` ,
2613
+ } ,
2614
+ } ,
2615
+ } ) ;
2616
+ } ) ;
0 commit comments