Automatic migration from synchronous to asynchronous JavaScript APIs
Satyajit Gokhale, Alexi Turcotte, Frank Tip
Abstract
The JavaScript ecosystem provides equivalent synchronous and asynchronous Application Programming Interfaces (APIs) for many commonly used I/O operations. Synchronous APIs involve straightforward sequential control flow that makes them easy to use and understand, but their "blocking" behavior may result in poor responsiveness or performance. Asynchronous APIs impose a higher syntactic burden that relies on callbacks, promises, and higher-order functions. On the other hand, their nonblocking behavior enables applications to scale better and remain responsive while I/O requests are being processed. While it is generally understood that asynchronous APIs have better performance characteristics, many applications still rely on synchronous APIs. In this paper, we present a refactoring technique for assisting programmers with the migration from synchronous to asynchronous APIs. The technique relies on static analysis to determine where calls to synchronous API functions can be replaced with their asynchronous counterparts, relying on JavaScript's async/await feature to minimize disruption to the source code. Since the static analysis is potentially unsound, the proposed refactorings are presented as suggestions that must be reviewed and confirmed by the programmer. The technique was implemented in a tool named Desynchronizer. In an empirical evaluation on 12 subject applications containing 316 synchronous API calls, Desynchronizer identified 256 of these as candidates for refactoring. Of these candidates, 244 were transformed successfully, and only 12 resulted in behavioral changes. Further inspection of these cases revealed that the majority of these issues can be attributed to unsoundness in the call graph.
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Your agent calls
Luneget_paper_fulltext
Free to start. No credit card required.
Terminal
Install the CLIlune papers fulltext 61ad4b72-fb1c-4577-8ca0-ecd840da11e7Cited by top-tier papers6
- DrAsync: Identifying and Visualizing Anti-Patterns in Asynchronous JavaScriptAlexi Turcotte, Michael D. Shah, Mark W. Aldrich, Frank TipICSE 2022 · 5 citations
- reformulator: Automated Refactoring of the N+1 Problem in Database-Backed ApplicationsAlexi Turcotte, Mark W. Aldrich, Frank TipASE 2022 · 3 citations
- Code Coverage Criteria for Asynchronous ProgramsMohammad Ganji, Saba Alimadadi, Frank TipFSE 2023 · 3 citations
- Increasing the Responsiveness of Web Applications by Introducing Lazy LoadingAlexi Turcotte, Satyajit Gokhale, Frank TipASE 2023 · 3 citations
- A Lightweight Polyglot Code Transformation LanguageAmeya Ketkar, Daniel Ramos, Lazaro Clapp, Raj Barik et al.PLDI 2024 · 1 citation
Related papers
- Semantic Patches for Adaptation of JavaScript Programs to Evolving LibrariesBenjamin Barslev Nielsen, Martin Toldam Torp, Anders MøllerICSE 2021 · 17 citations
- Static asynchronous component misuse detection for Android applicationsLinjie Pan, Baoquan Cui, Hao Liu, Jiwei Yan et al.FSE 2020 · 10 citations
- Reducing Static Analysis Unsoundness with Approximate InterpretationMathias Rud Laursen, Wenyuan Xu, Anders MøllerPLDI 2024 · 5 citations
- Detecting locations in JavaScript programs affected by breaking library changesAnders Møller, Benjamin Barslev Nielsen, Martin Toldam TorpOOPSLA 2020 · 32 citations
- Automatically deriving JavaScript static analyzers from specifications using Meta-level static analysisJihyeok Park, Seungmin An, Sukyoung RyuFSE 2022 · 10 citations
