DrAsync: Identifying and Visualizing Anti-Patterns in Asynchronous JavaScript
Alexi Turcotte, Michael D. Shah, Mark W. Aldrich, Frank Tip
摘要
Promises and async/await have become popular mechanisms for implementing asynchronous computations in JavaScript, but despite their popularity, programmers have difficulty using them. This paper identifies 8 anti-patterns in promise-based JavaScript code that are prevalent across popular JavaScript repositories. We present a light-weight static analysis for automatically detecting these anti-patterns. This analysis is embedded in an interactive visualization tool that additionally relies on dynamic analysis to visualize promise lifetimes and instances of anti-patterns executed at run time. By enabling the user to navigate between promises in the visualization and the source code fragments that they originate from, problems and optimization opportunities can be identified. We implement this approach in a tool called DrAsync, and found 2.6K static instances of anti-patterns in 20 popular JavaScript repositories. Upon examination of a subset of these, we found that the majority of problematic code reported by DrAsync could be eliminated through refactoring. Further investigation revealed that, in a few cases, the elimination of anti-patterns reduced the time needed to execute the refactored code fragments. Moreover, DrAsync's visualization of promise lifetimes and relationships provides additional insight into the execution behavior of asynchronous programs and helped identify further optimization opportunities.
问 Lune
几分钟读透这篇 Paper,不用再花一下午。
Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。
已有 2 篇顶会 Paper 引用了它。别等审稿人问起,先弄清它们发现了什么。
脉络
- Preserving Reactiveness: Understanding and Improving the Debugging Practice of Blocking-Call Bugs 引用了 Automatic migration from synchronous to asynchronous JavaScript APIs
- Code Coverage Criteria for Asynchronous Programs 引用了 Automatic migration from synchronous to asynchronous JavaScript APIs
引用它的顶会 Paper2
它引用的 Paper1
相关 Paper
- Detecting locations in JavaScript programs affected by breaking library changesAnders Møller, Benjamin Barslev Nielsen, Martin Toldam TorpOOPSLA 2020 · 32 次引用
- Static asynchronous component misuse detection for Android applicationsLinjie Pan, Baoquan Cui, Hao Liu, Jiwei Yan 等FSE 2020 · 10 次引用
- Increasing the Responsiveness of Web Applications by Introducing Lazy LoadingAlexi Turcotte, Satyajit Gokhale, Frank TipASE 2023 · 3 次引用
- Semantic Patches for Adaptation of JavaScript Programs to Evolving LibrariesBenjamin Barslev Nielsen, Martin Toldam Torp, Anders MøllerICSE 2021 · 17 次引用
- DyLin: A Dynamic Linter for PythonAryaz Eghbali, Felix Burk, Michael PradelFSE 2025 · 1 次引用
