nodejs / nodejs/node

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

Abierto
#42,743 0 comentarios 2 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

confirmed-bug perf_hooks
Lenguaje dominante
JavaScript
Estrellas
122k
Forks
37.3k
Merge medio
4 d 2 h
PR fusionados (30 d)
283

Descripción

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.

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza en el punto de entrada perf_hooks performance.timerify y reproduce los ejemplos sync y async proporcionados con histogramas. Inspecciona cómo se gestionan las promises devueltas y los errores lanzados; se considera terminado cuando las funciones sync timerified y las funciones que devuelven promises muestran un comportamiento coherente de registro en histogramas, incluidos los thenables.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
javascript
Área
performance
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bien especificado
Aptitud para principiantes
48/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.