Skip to content

Commit

Permalink
fix: Fix dereference of undefined (#363)
Browse files Browse the repository at this point in the history
Fixed dereference of undefined on fnReturn when user function does not
return/returns undefined.

Fixed error in logging.

Signed-off-by: Matej Vašek <matejvasek@gmail.com>
  • Loading branch information
matejvasek authored Oct 29, 2024
1 parent ffa5b53 commit 473a23f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/invoker.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module.exports = function invoker(opts) {

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

function handleError(err, log) {
log.error('Error processing user function', err);
log.error(`Error processing user function: "${err}"`);
return {
code: err.code ? err.code : 500,
response: err.message
Expand Down

0 comments on commit 473a23f

Please sign in to comment.