@@ -20,6 +20,12 @@ import { VMWorkflow, VMWorkflowCreator } from '@temporalio/worker/lib/workflow/v
2020import { SdkFlag , SdkFlags } from '@temporalio/workflow/lib/flags' ;
2121import { ReusableVMWorkflow , ReusableVMWorkflowCreator } from '@temporalio/worker/lib/workflow/reusable-vm' ;
2222import { 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' ;
2329import * as activityFunctions from './activities' ;
2430import { cleanStackTrace , REUSE_V8_CONTEXT , u8 } from './helpers' ;
2531import { ProcessedSignal } from './workflows' ;
@@ -2528,3 +2534,83 @@ test('Signals/Updates/Activities/Timers - Trace promises completion order - 1.11
25282534 ) ;
25292535 }
25302536} ) ;
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