Due to the popularity of Node.js, asynchronous, event-driven programming has become widespread in server-side applications. While conceptually simple, event-based programming can be tedious and error-prone. The complex semantics of the Node.js event loop, coupled with the different flavors of asynchronous execution in JavaScript, can easily lead to bugs.
To deal with this problem, we have introduced a new model called Async Graph to reason about the runtime behavior of applications and their interactions with the Node.js event loop. Based on the model, we have developed AsyncG, a tool to automatically build and analyze the Async Graph of a running application, and to identify bugs related to all sources of asynchronous execution in Node.js. AsyncG is built on top of NodeProf, is compatible with the latest ECMAScript language features, and can be (de)activated at runtime.
Our tool outperforms other similar dynamic analysis tools thanks to the use of NodeProf, since 1) AsyncG supports async/await features while other similar tools do not, 2) the tool offers a more comprehensive coverage of the event loop thanks to its ability to instrument Node.js libraries, and 3) AsyncG can be applied in realistic server-side applications with limited overhead. Moreover, we used AsyncG to conduct a large-scale study with NAB on the use of promises in open-source projects hosted on GitHub.
This work has been published at CGO’19 [1] and received three badges related to the artifact evaluation process (“Artifacts Functional”, “Artifacts Available”, “Results Replicated”). AsyncG has been released open-source on GitHub [A].
Key Publications
[1] Haiyang Sun, Daniele Bonetta, Filippo Schiavio, Walter Binder: Reasoning about the Node.js Event Loop using Async Graphs. CGO 2019: 61-72 [pdf]
Software
[A] See the software page