File tree Expand file tree Collapse file tree 3 files changed +27
-0
lines changed
src/implementation/Client Expand file tree Collapse file tree 3 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -248,6 +248,13 @@ export default class GRPCClientState implements IClientState {
248
248
if ( err ) {
249
249
return reject ( err ) ;
250
250
}
251
+ const resultsList = res . getResultsList ( ) ;
252
+ if ( resultsList . length === 0 ) {
253
+ return resolve ( {
254
+ results : [ ] ,
255
+ token : res . getToken ( ) ,
256
+ } as StateQueryResponseType ) ;
257
+ }
251
258
252
259
// https://docs.dapr.io/reference/api/state_api/#response-body
253
260
// map the res from gRPC
Original file line number Diff line number Diff line change @@ -103,6 +103,10 @@ export default class HTTPClientState implements IClientState {
103
103
} ,
104
104
} ) ;
105
105
106
+ if ( result === "" ) {
107
+ return { results : [ ] } as StateQueryResponseType ;
108
+ }
109
+
106
110
return result as StateQueryResponseType ;
107
111
}
108
112
}
Original file line number Diff line number Diff line change @@ -464,5 +464,21 @@ describe("common/client", () => {
464
464
await httpClient . state . delete ( stateStoreMongoDbName , `key-${ i } ` ) ;
465
465
}
466
466
} ) ;
467
+
468
+ it ( "should return an empty object when result is empty" , async ( ) => {
469
+ const result = await httpClient . state . query ( stateStoreMongoDbName , {
470
+ filter : { EQ : { state : "statenotfound" } } ,
471
+ sort : [
472
+ {
473
+ key : "state" ,
474
+ order : "DESC" ,
475
+ } ,
476
+ ] ,
477
+ page : {
478
+ limit : 10 ,
479
+ } ,
480
+ } ) ;
481
+ expect ( result ) . toEqual ( { results : [ ] } ) ;
482
+ } ) ;
467
483
} ) ;
468
484
} ) ;
You can’t perform that action at this time.
0 commit comments