You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
performance.timerify doesn't return wrapped function's return value #40623
Darwin AC-MacBook-Pro.hsd1.ca.comcast.net 20.6.0 Darwin Kernel Version 20.6.0: Mon Aug 30 06:12:21 PDT 2021; root:xnu-7195.141.6~3/RELEASE_X86_64 x86_64 i386 MacBookPro16,1 Darwin
Subsystem
performance
What steps will reproduce the bug?
const perf = performance.timerify(function foo() {
let sum = 0;
for (let i = 0; i < 1000000; i++) {
sum += i;
}
return sum;
});
const result = perf();
console.log(result);
How often does it reproduce? Is there a required condition?
Activity
targos commentedon Oct 27, 2021
Seems like a bug to me indeed. The function is called as a constructor and it returns an instance of it instead of the true return value.
targos commentedon Oct 27, 2021
/cc @jasnell
hax commentedon Apr 12, 2022
Caught by this bug today!
Workaround: using arrow function.
hax commentedon Apr 18, 2022
Note, node 14 do not have this bug. So it's the bug of rewriting it from C++ to JS :-)