From 92a2d84701e04a7247e462ab1dd9ae9a26559900 Mon Sep 17 00:00:00 2001 From: Danilo Resende Date: Tue, 27 Nov 2018 11:15:45 -0200 Subject: [PATCH] Cache `req.miniprofiler` into a local With the addition of `async_hooks` [0] the `req.miniprofiler` is now a getter, and some Redis methods don't plays nice with it. [0]: https://github.com/MiniProfiler/node/pull/7 --- index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index b9585b2..0d6eee2 100755 --- a/index.js +++ b/index.js @@ -16,8 +16,10 @@ module.exports = function(redis) { if (callback && req && req.miniprofiler) { const query = `${cmd.command} ${cmd.args.join(', ')}`.trim(); const timing = req.miniprofiler.startTimeQuery('redis', query); + const miniprofiler = req.miniprofiler; + cmd.callback = function() { - req.miniprofiler.stopTimeQuery(timing); + miniprofiler.stopTimeQuery(timing); callback.apply(this, arguments); }; }