From d3eb446cf9abc0a5acf675e56a92a3fec1c6ced8 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Sun, 25 Mar 2018 01:25:36 +0430 Subject: [PATCH] fix(profile): ignore requests without any file or loaders --- src/profile.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/profile.js b/src/profile.js index 32b3de3..14a1aed 100644 --- a/src/profile.js +++ b/src/profile.js @@ -7,9 +7,18 @@ export default class Profile { } onRequest(request) { + // Measure time for last request if (this.requests.length) { - this.requests[this.requests.length - 1].time = process.hrtime(this.requests[this.requests.length - 1].start); - delete this.requests[this.requests.length - 1].start; + const lastReq = this.requests[this.requests.length - 1]; + if (lastReq.start) { + lastReq.time = process.hrtime(lastReq.start); + delete lastReq.start; + } + } + + // Ignore requests without any file or loaders + if (!request.file || !request.loaders.length) { + return; } this.requests.push({ @@ -46,6 +55,9 @@ export default class Profile { }); const ext = request.file && path.extname(request.file).substr(1); + if (!ext || !ext.length) { + console.log(request); + } addToStat(extStats, ext && ext.length ? ext : 'unknown', 1, time); });