From 548cbf0625cdfc8827de2dcdb84548fa8b17a290 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Fri, 9 Apr 2021 13:08:28 +0200 Subject: [PATCH] perf_hooks: fix loop delay resolution validation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: https://github.com/nodejs/node/issues/38160 PR-URL: https://github.com/nodejs/node/pull/38166 Reviewed-By: Anna Henningsen Reviewed-By: Gerhard Stöbich Reviewed-By: Luigi Pinca Reviewed-By: James M Snell Reviewed-By: Colin Ihrig --- src/node_perf.cc | 4 ++-- src/node_perf.h | 2 +- test/sequential/test-performance-eventloopdelay.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/node_perf.cc b/src/node_perf.cc index 2d6341e01136fe..c1a0b2cf3a14d7 100644 --- a/src/node_perf.cc +++ b/src/node_perf.cc @@ -237,7 +237,7 @@ void LoopIdleTime(const FunctionCallbackInfo& args) { void ELDHistogram::New(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); CHECK(args.IsConstructCall()); - int32_t resolution = args[0].As()->Value(); + int64_t resolution = args[0].As()->Value(); CHECK_GT(resolution, 0); new ELDHistogram(env, args.This(), resolution); } @@ -253,7 +253,7 @@ void ELDHistogram::Initialize(Environment* env, Local target) { ELDHistogram::ELDHistogram( Environment* env, Local wrap, - int32_t interval) + int64_t interval) : IntervalHistogram( env, wrap, diff --git a/src/node_perf.h b/src/node_perf.h index d0f1d68462265c..33cf9f2ec651bf 100644 --- a/src/node_perf.h +++ b/src/node_perf.h @@ -166,7 +166,7 @@ class ELDHistogram : public IntervalHistogram { ELDHistogram( Environment* env, v8::Local wrap, - int32_t interval); + int64_t interval); void OnInterval() override; diff --git a/test/sequential/test-performance-eventloopdelay.js b/test/sequential/test-performance-eventloopdelay.js index b12d3a72341ee9..f262e9de3fe6cb 100644 --- a/test/sequential/test-performance-eventloopdelay.js +++ b/test/sequential/test-performance-eventloopdelay.js @@ -39,7 +39,7 @@ const { sleep } = require('internal/util'); ); }); - [-1, 0, Infinity].forEach((i) => { + [-1, 0, 2 ** 53, Infinity].forEach((i) => { assert.throws( () => monitorEventLoopDelay({ resolution: i }), {