performance.timerify(fn) behave inconsistently for sync/async functions
まだ誰も着手していません。
- 主要言語
- JavaScript
- スター
- 122k
- フォーク
- 37.4k
- 平均マージ
- 4日 3時間
- マージ済み PR(30日)
- 272
説明
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.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
perf_hooks performance.timerify のエントリポイントから始め、ヒストグラムを使って提示された sync および async の例を再現します。返された promises とスローされたエラーがどのように処理されるかを調べます。完了条件は、timerified な sync 関数と promise を返す関数が、thenables を含め、一貫したヒストグラム記録動作を持つことです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript
- 領域
- performance
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 48/100