Skip to content
This repository was archived by the owner on Aug 23, 2019. It is now read-only.

Commit 7aebb9c

Browse files
kumavisjacobheun
authored andcommitted
fix(stats): prevent 0ms timeDiff breaking movingAverage (#336)
* stats - stat - prevent 0ms timeDiff breaking movingAverage * chore: remove commitlint
1 parent c73efba commit 7aebb9c

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ jobs:
2222

2323
- stage: check
2424
script:
25-
- npx aegir commitlint --travis
2625
- npx aegir dep-check
2726
- npm run lint
2827

src/stats/stat.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,9 @@ class Stats extends EventEmitter {
182182
_updateFrequencyFor (key, timeDiffMS, latestTime) {
183183
const count = this._frequencyAccumulators[key] || 0
184184
this._frequencyAccumulators[key] = 0
185-
const hz = (count / timeDiffMS) * 1000
185+
// if `timeDiff` is zero, `hz` becomes Infinity, so we fallback to 1ms
186+
const safeTimeDiff = timeDiffMS || 1
187+
const hz = (count / safeTimeDiff) * 1000
186188

187189
let movingAverages = this._movingAverages[key]
188190
if (!movingAverages) {

0 commit comments

Comments
 (0)