Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

performance.timerify(fn) behave inconsistently for sync/async functions #42743

Open
hax opened this issue Apr 14, 2022 · 0 comments · May be fixed by #42883
Open

performance.timerify(fn) behave inconsistently for sync/async functions #42743

hax opened this issue Apr 14, 2022 · 0 comments · May be fixed by #42883
Labels
confirmed-bug Issues with confirmed bugs. perf_hooks Issues and PRs related to the implementation of the Performance Timing API.

Comments

@hax
Copy link
Contributor

hax commented Apr 14, 2022

Version

master branch

Platform

All

Subsystem

perf_hooks

What steps will reproduce the bug?

function f1() { throw new Error() }
async function f2() { throw new Error() }
let h1 = perf_hooks.createHistogram()
let h2 = perf_hooks.createHistogram()
let g1 = perf_hooks.performance.timerify(f1, {histogram: h1})
let g2 = perf_hooks.performance.timerify(f2, {histogram: h2})
g1()
await g2()
h1.count === h2.count // expect true, actual false

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior?

Timerified functions should behave consistently for whether trigger histogram.record.

What do you see instead?

Currently, normal function would not trigger histogram.record if throw; but async function (or any function which return promise) would.

Additional information

Currently, the code is like if (typeof result?.finally === 'function') return result.finally(...). It should use result.then instead, so the behavior will consistent with non-thenable result. Even we want to always trigger histogram.record, we should not use finally because thenable is only require to have then method, not finally method.

@VoltrexKeyva VoltrexKeyva added the perf_hooks Issues and PRs related to the implementation of the Performance Timing API. label Apr 14, 2022
@himself65 himself65 added the confirmed-bug Issues with confirmed bugs. label Apr 23, 2022
@iam-frankqiu iam-frankqiu linked a pull request Apr 27, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed-bug Issues with confirmed bugs. perf_hooks Issues and PRs related to the implementation of the Performance Timing API.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants