Skip to content

Commit 473a23f

Browse files
authored
fix: Fix dereference of undefined (#363)
Fixed dereference of undefined on fnReturn when user function does not return/returns undefined. Fixed error in logging. Signed-off-by: Matej Vašek <[email protected]>
1 parent ffa5b53 commit 473a23f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/invoker.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ module.exports = function invoker(opts) {
3434

3535
// If the response is a CloudEvent, we need to convert it
3636
// to a Message first and respond with the headers/body
37-
if (fnReturn instanceof CloudEvent || fnReturn.constructor?.name === 'CloudEvent') {
37+
if (fnReturn instanceof CloudEvent || fnReturn?.constructor?.name === 'CloudEvent') {
3838
try {
3939
const message = HTTP.binary(fnReturn);
4040
payload.headers = { ...payload.headers, ...message.headers };
@@ -121,7 +121,7 @@ module.exports = function invoker(opts) {
121121
};
122122

123123
function handleError(err, log) {
124-
log.error('Error processing user function', err);
124+
log.error(`Error processing user function: "${err}"`);
125125
return {
126126
code: err.code ? err.code : 500,
127127
response: err.message

0 commit comments

Comments
 (0)