Skip to content

Commit

Permalink
fix: check context before context.toJSON (#187)
Browse files Browse the repository at this point in the history
  • Loading branch information
palmtown committed Apr 7, 2023
1 parent 622fbe2 commit e8ac24e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/core.js
Expand Up @@ -52,7 +52,7 @@ module.exports = app => {
return this._emit(event, data, ctx);
}

const serializedContext = typeof ctx.toJSON === 'function' ? ctx.toJSON() : ctx;
const serializedContext = ctx && typeof ctx.toJSON === 'function' ? ctx.toJSON() : ctx;
const context = ctx && (ctx.app === app || ctx.service === service)
? _.omit(serializedContext, 'app', 'service', 'self')
: serializedContext;
Expand Down

0 comments on commit e8ac24e

Please sign in to comment.