From ca6fede72c3da4da68582912e485cc674552407d Mon Sep 17 00:00:00 2001 From: rajasekharan Date: Fri, 1 Jun 2018 14:22:48 +0530 Subject: [PATCH] check for res on context exit --- context.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/context.js b/context.js index e729e45..bef8f8d 100644 --- a/context.js +++ b/context.js @@ -55,7 +55,16 @@ Namespace.prototype.run = function (fn) { throw exception; } finally { - this.exit(context); + if (context && context.res) { + var self = this; + context.res.on('finish', function () { + // response was sent. kill the context + self.exit(context); + }); + } else { + // default action + this.exit(context); + } } };