File tree Expand file tree Collapse file tree 3 files changed +29
-1
lines changed Expand file tree Collapse file tree 3 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -611,6 +611,9 @@ export class WorkflowClient {
611
611
} ,
612
612
} ) ;
613
613
} catch ( err ) {
614
+ if ( isServerErrorResponse ( err ) && err . code === grpcStatus . INVALID_ARGUMENT ) {
615
+ throw new QueryNotRegisteredError ( err . message . replace ( / ^ 3 I N V A L I D _ A R G U M E N T : / , '' ) , err . code ) ;
616
+ }
614
617
this . rethrowGrpcError ( err , input . workflowExecution , 'Failed to query Workflow' ) ;
615
618
}
616
619
if ( response . queryRejected ) {
@@ -938,6 +941,13 @@ export class QueryRejectedError extends Error {
938
941
}
939
942
}
940
943
944
+ export class QueryNotRegisteredError extends Error {
945
+ public readonly name : string = 'QueryNotRegisteredError' ;
946
+ constructor ( message : string , public readonly code : grpcStatus ) {
947
+ super ( message ) ;
948
+ }
949
+ }
950
+
941
951
function workflowStatusCodeToName ( code : temporal . api . enums . v1 . WorkflowExecutionStatus ) : WorkflowExecutionStatusName {
942
952
return workflowStatusCodeToNameInternal ( code ) ?? 'UNKNOWN' ;
943
953
}
Original file line number Diff line number Diff line change 3
3
ActivityFailure ,
4
4
ApplicationFailure ,
5
5
Connection ,
6
+ QueryNotRegisteredError ,
6
7
WorkflowClient ,
7
8
WorkflowContinuedAsNewError ,
8
9
WorkflowFailedError ,
@@ -391,6 +392,20 @@ export function runIntegrationTests(codec?: PayloadCodec): void {
391
392
t . pass ( ) ;
392
393
} ) ;
393
394
395
+ test ( 'query not found' , async ( t ) => {
396
+ const { client } = t . context ;
397
+ const workflow = await client . start ( workflows . unblockOrCancel , {
398
+ taskQueue : 'test' ,
399
+ workflowId : uuid4 ( ) ,
400
+ } ) ;
401
+ await workflow . signal ( workflows . unblockSignal ) ;
402
+ await workflow . result ( ) ;
403
+ await t . throwsAsync ( workflow . query ( 'not found' ) , {
404
+ instanceOf : QueryNotRegisteredError ,
405
+ message : 'Workflow did not register a handler for not found. Registered queries: [__stack_trace isBlocked]' ,
406
+ } ) ;
407
+ } ) ;
408
+
394
409
test ( 'query and unblock' , async ( t ) => {
395
410
const { client } = t . context ;
396
411
const workflow = await client . start ( workflows . unblockOrCancel , {
Original file line number Diff line number Diff line change @@ -212,8 +212,11 @@ export class Activator implements ActivationHandler {
212
212
protected queryWorkflowNextHandler ( { queryName, args } : QueryInput ) : Promise < unknown > {
213
213
const fn = state . queryHandlers . get ( queryName ) ;
214
214
if ( fn === undefined ) {
215
+ const knownQueryTypes = [ ...state . queryHandlers . keys ( ) ] . join ( ' ' ) ;
215
216
// Fail the query
216
- throw new ReferenceError ( `Workflow did not register a handler for ${ queryName } ` ) ;
217
+ throw new ReferenceError (
218
+ `Workflow did not register a handler for ${ queryName } . Registered queries: [${ knownQueryTypes } ]`
219
+ ) ;
217
220
}
218
221
try {
219
222
const ret = fn ( ...args ) ;
You can’t perform that action at this time.
0 commit comments