Skip to content

Commit

Permalink
Cache req.miniprofiler into a local
Browse files Browse the repository at this point in the history
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]: MiniProfiler/node#7
  • Loading branch information
Danilo Resende committed Nov 27, 2018
1 parent 44e23a5 commit 92a2d84
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
}
Expand Down

0 comments on commit 92a2d84

Please sign in to comment.