diff --git a/lib/core.js b/lib/core.js index 570fdd3..b64b063 100644 --- a/lib/core.js +++ b/lib/core.js @@ -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;