Abstract
JavaScript code running in the Node.js runtime is a major platform for developers building cloud, mobile, or IoT applications. A fundamental concept in Node.js programming is the use of asynchronous callbacks and event loops to provide highly responsive applications. While conceptually simple, this programming model contains numerous subtleties and behaviors that are defined implicitly by the current Node.js implementation. This paper presents the first comprehensive formalization of the Node.js asynchronous execution model and defines a high-level notion of async-contexts to formalize fundamental relationships between asynchronous executions in an application. These formalizations provide a foundation for the construction of static or dynamic program analysis tools, support the exploration of alternative Node.js event loop implementations, and provide a high-level conceptual framework for reasoning about relationships between the execution of asynchronous callbacks in a Node.js application.
- Martín Abadi, and Gordon D. Plotkin. “A Model of Cooperative Threads” 6 (4:2): 1–39. 2010. doi: 10.2168/LMCS-6(4:2)2010 . Google Scholar
Cross Ref
- Christoffer Quist Adamsen, Anders Møller, Rezwana Karim, Manu Sridharan, Frank Tip, and Koushik Sen. “Repairing Event Race Errors by Controlling Nondeterminism.” In Proceedings of the 39th International Conference on Software Engineering (ICSE’17). 2017. doi: 10.1109/ICSE.2017.34 . Google Scholar
Digital Library
- Saba Alimadadi, Ali Mesbah, and Karthik Pattabiraman. “Understanding Asynchronous Interactions in Full-Stack JavaScript.” In Proceedings of the 38th International Conference on Software Engineering (ICSE’16). 2016. doi: 10.1145/2884781.2884864 . Google Scholar
Digital Library
- Earl T. Barr, Mark Marron, Ed Maurer, Dan Moseley, and Gaurav Seth. “Time-Travel Debugging for JavaScript/Node.js.” In Proceedings of the 2016 ACM International Symposium on the Foundations of Software Engineering (FSE’16). Nov. 2016. doi: 10.1145/2950290.2983933 . Google Scholar
Digital Library
- Dave Berry, Robin Milner, and David N. Turner. “A Semantics for ML Concurrency Primitives.” In Proceedings of the 19th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, 119–129. POPL’92. Albuquerque, New Mexico, USA. 1992. doi: 10.1145/143165.143191 . Google Scholar
Digital Library
- Gérard Boudol. “Fair Cooperative Multithreading.” In Concurrency Theory: 18th International Conference, edited by Luís Caires and Vasco T. Vasconcelos, 272–286. CONCUR’07. Lisbon, Portugal. Sep. 2007. doi: 10.1007/978-3-540-74407-8_19 . Google Scholar
Cross Ref
- Frédéric Boussinot. “FairThreads: Mixing Cooperative and Preemptive Threads in C.” Concurrent Computation: Practice and Experience 18 (5): 445–469. Apr. 2006. doi: 10.1002/cpe.v18:5 . Google Scholar
Digital Library
- James Davis, Arun Thekumparampil, and Dongyoon Lee. “Node.Fz: Fuzzing the Server-Side Event-Driven Architecture.” In Proceedings of the Twelfth European Conference on Computer Systems (EuroSys’17). 2017. doi: 10.1145/3064176.3064188 . Google Scholar
Digital Library
- Ankush Desai, Shaz Qadeer, and Sanjit A. Seshia. “Systematic Testing of Asynchronous Reactive Systems.” In Proceedings of the 2015 10th Joint Meeting on Foundations of Software Engineering (FSE’15). 2015. doi: 10.1145/2786805.2786861 . Google Scholar
Digital Library
- Glimpse. 2016. http://node.getglimpse.com .Google Scholar
- Arjun Guha, Claudiu Saftoiu, and Shriram Krishnamurthi. “The Essence of Javascript.” In Proceedings of the 24th European Conference on Object-Oriented Programming (ECOOP’10). 2010. doi: 10.1007/978-3-642-14107-2_7 . Google Scholar
Cross Ref
- Async Hooks. 2016. https://github.com/nodejs/diagnostics/tree/ master/tracing/AsyncWrap .Google Scholar
- Ecma International. 2015. https://www.ecma-international.org/ecma262/6.0/#sec-promise-objects .Google Scholar
- Daan Leijen. Structured Asynchrony Using Algebraic Effects. MSR-TR-2017-21. Microsoft Research. May 2017.Google Scholar
- Magnus Madsen, Frank Tip, and Ondřej Lhoták. “Static Analysis of Event-Driven Node.js JavaScript Applications.” In Conference on ObjectOriented Programming, Systems, Languages, and Applications (OOP-SLA’15), 505–519. Oct. 2015. doi: 10.1145/2858965.2814272 . Google Scholar
Digital Library
- Madanlal Musuvathi, and Shaz Qadeer. “Fair Stateless Model Checking.” In Proceedings of the 29th ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI’08). 2008. doi: 10.1145/1375581.1375625 . Google Scholar
Digital Library
- Erdal Mutlu, Serdar Tasiran, and Benjamin Livshits. “Detecting JavaScript Races That Matter.” In Proceedings of the 2015 10th Joint Meeting on Foundations of Software Engineering (FSE’15). 2015. doi: 10.1145/2786805.2786820 . Google Scholar
Digital Library
- Node.js Foundation. 2017. https://nodejs.org/api/process.html# process_process_nexttick_callback_args .Google Scholar
- NSolid. 2015. https://nodesource.com/products/nsolid .Google Scholar
- Gordon D. Plotkin, and John Power. “Algebraic Operations and Generic Effects.” Applied Categorical Structures 11 (1): 69–94. 2003. doi: 10.1023/A:1023064908962 . Google Scholar
Cross Ref
- Gordon D. Plotkin, and Matija Pretnar. “Handlers of Algebraic Effects.” In 18th European Symposium on Programming Languages and Systems, 80–94. ESOP’09. York, UK. Mar. 2009. doi: 10.1007/978-3-642-00590-9_7 . Google Scholar
Digital Library
- Promise/A. “Promise/A+ Specification.” 2014. https://promisesaplus. com .Google Scholar
- New Relic. 2012. https://newrelic.com/nodejs .Google Scholar
- Stackdriver. 2015. https://cloud.google.com/trace/ .Google Scholar
- Async Call Stacks. 2014. http://www.html5rocks.com/en/tutorials/ developertools/async-call-stack/ .Google Scholar
- Zones. 2014. https://github.com/angular/zone.js .Google Scholar
Index Terms
Semantics of asynchronous JavaScript
Recommendations
Semantics of asynchronous JavaScript
DLS 2017: Proceedings of the 13th ACM SIGPLAN International Symposium on on Dynamic LanguagesJavaScript code running in the Node.js runtime is a major platform for developers building cloud, mobile, or IoT applications. A fundamental concept in Node.js programming is the use of asynchronous callbacks and event loops to provide highly ...







Comments