diff --git a/lib/internal/histogram.js b/lib/internal/histogram.js index 00149db50236da..f599e4b3edb5f5 100644 --- a/lib/internal/histogram.js +++ b/lib/internal/histogram.js @@ -5,7 +5,7 @@ const { } = require('internal/util'); const { format } = require('util'); -const { SafeMap, Symbol } = primordials; +const { NumberIsNaN, SafeMap, Symbol } = primordials; const { ERR_INVALID_ARG_TYPE, @@ -61,7 +61,7 @@ class Histogram { if (typeof percentile !== 'number') throw new ERR_INVALID_ARG_TYPE('percentile', 'number', percentile); - if (percentile <= 0 || percentile > 100) + if (NumberIsNaN(percentile) || percentile <= 0 || percentile > 100) throw new ERR_INVALID_ARG_VALUE.RangeError('percentile', percentile); return this[kHandle]?.percentile(percentile); diff --git a/test/sequential/test-performance-eventloopdelay.js b/test/sequential/test-performance-eventloopdelay.js index 5021ee98073d0e..b23e0977428347 100644 --- a/test/sequential/test-performance-eventloopdelay.js +++ b/test/sequential/test-performance-eventloopdelay.js @@ -86,7 +86,7 @@ const { sleep } = require('internal/util'); } ); }); - [-1, 0, 101].forEach((i) => { + [-1, 0, 101, NaN].forEach((i) => { assert.throws( () => histogram.percentile(i), {