Skip to content

Commit 2009088

Browse files
committed
Improve null response handling
1 parent f855977 commit 2009088

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

lib/server/gRPC/bindGRPCController.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ const adaptGrpcServiceMethodToControllerHandler = (
8686

8787
const response = await controllerHandler(request);
8888

89-
if (!response) {
90-
return response;
89+
if (!(typeof response === 'object') || response === null) {
90+
return null;
9191
}
9292

9393
// Apply the gRPC converter to all the request parameters that needs it
@@ -129,8 +129,8 @@ const bindGRPCController = (serviceDefinition, implementation, absoluteMessagesD
129129
try {
130130
const response = await adapter(call);
131131

132-
if (response === null || response === undefined) {
133-
callback(nativeToGRPCError(new Error(`Controller for ${path} returned a null response`)));
132+
if (response === null) {
133+
callback(nativeToGRPCError(new Error(`Controller for ${path} returned an invalid response`)));
134134
} else {
135135
callback(null, response);
136136
}

0 commit comments

Comments
 (0)