{"record":{"id":"8d427c0426b4286f","repo":"denoland/deno","slug":"err-out-of-range-8d427c","errorCode":"ERR_OUT_OF_RANGE","errorMessage":"The value of \"percentile\" is out of range. It must be > 0 && <= 100. Received ${received}","messagePattern":"The value of \"percentile\" is out of range\\. It must be > 0 && <= 100\\. Received (.+?)","errorType":"exception","errorClass":"ERR_OUT_OF_RANGE","httpStatus":null,"severity":"error","filePath":"ext/node/polyfills/perf_hooks.js","lineNumber":421,"sourceCode":"      MapPrototypeSet(out, 0, this.minBigInt);\n      for (\n        let percentile = 50;\n        percentile < 100;\n        percentile += (100 - percentile) / 2\n      ) {\n        MapPrototypeSet(out, percentile, this.percentileBigInt(percentile));\n        if (percentile > 99.999) break;\n      }\n      MapPrototypeSet(out, 100, this.maxBigInt);\n    }\n    return out;\n  }\n  percentile(p) {\n    if (typeof p !== \"number\") {\n      throw new ERR_INVALID_ARG_TYPE(\"percentile\", \"number\", p);\n    }\n    if (!(p > 0 && p <= 100)) {\n      throw new ERR_OUT_OF_RANGE(\"percentile\", \"> 0 && <= 100\", p);\n    }\n    return this[_handle].percentile(p);\n  }\n  percentileBigInt(p) {\n    if (typeof p !== \"number\") {\n      throw new ERR_INVALID_ARG_TYPE(\"percentile\", \"number\", p);\n    }\n    if (!(p > 0 && p <= 100)) {\n      throw new ERR_OUT_OF_RANGE(\"percentile\", \"> 0 && <= 100\", p);\n    }\n    return BigInt(this[_handle].percentileBigInt(p));\n  }\n  reset() {\n    this[_handle].reset();\n  }\n  toJSON() {\n    return {\n      count: this.count,","sourceCodeStart":403,"sourceCodeEnd":439,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/ext/node/polyfills/perf_hooks.js#L403-L439","documentation":"Histogram.percentile(p) validates 0 < p <= 100. Because the guard is `!(p > 0 && p <= 100)`, NaN and Infinity are also rejected, not just values outside the window. ERR_OUT_OF_RANGE is thrown after the type check passes.","triggerScenarios":"h.percentile(0); h.percentile(101); h.percentile(-5); h.percentile(NaN) (e.g. parseFloat(\"p50\")); h.percentile(Infinity).","commonSituations":"Passing a fraction (0.5 meaning 50%) instead of a percentage; NaN leaking from failed parses or missing config keys; arithmetic like p = a/b with b = 0.","solutions":["Scale fractions by 100 before calling (0.99 → 99)","Validate first: Number.isFinite(p) && p > 0 && p <= 100","Fix the NaN source (bad parse, undefined variable) — the range error is often a symptom, not the bug"],"exampleFix":"// before\nh.percentile(ratio); // ratio = 0.99\n\n// after\nh.percentile(ratio * 100); // 99","handlingStrategy":"validation","validationCode":"if (!(Number.isFinite(p) && p > 0 && p <= 100)) {\n  throw new RangeError(`percentile must be > 0 and <= 100, got ${p}`);\n}\nreturn h.percentile(p);","typeGuard":"const isValidPercentile = (p) => Number.isFinite(p) && p > 0 && p <= 100;","tryCatchPattern":"try {\n  v = h.percentile(p);\n} catch (err) {\n  if (err.code === \"ERR_OUT_OF_RANGE\") {\n    v = h.percentile(Math.min(Math.max(p, 0.001), 100)); // clamp and retry once\n  } else throw err;\n}","preventionTips":["Convert ratios to percentages at the boundary (×100)","Unit-test percentile plumbing with 0, 100, 101, NaN, and negative inputs"],"tags":["perf-hooks","histogram","percentile","out-of-range","node-compat"],"backgroundTag":"argument-out-of-range","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}