skip to main content
article
Open Access

Semantics of asynchronous JavaScript

Published:24 October 2017Publication History
Skip Abstract Section

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.

References

  1. 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 ScholarGoogle ScholarCross RefCross Ref
  2. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  3. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  4. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  5. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  6. 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 ScholarGoogle ScholarCross RefCross Ref
  7. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  8. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  9. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  10. Glimpse. 2016. http://node.getglimpse.com .Google ScholarGoogle Scholar
  11. 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 ScholarGoogle ScholarCross RefCross Ref
  12. Async Hooks. 2016. https://github.com/nodejs/diagnostics/tree/ master/tracing/AsyncWrap .Google ScholarGoogle Scholar
  13. Ecma International. 2015. https://www.ecma-international.org/ecma262/6.0/#sec-promise-objects .Google ScholarGoogle Scholar
  14. Daan Leijen. Structured Asynchrony Using Algebraic Effects. MSR-TR-2017-21. Microsoft Research. May 2017.Google ScholarGoogle Scholar
  15. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  16. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  17. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  18. Node.js Foundation. 2017. https://nodejs.org/api/process.html# process_process_nexttick_callback_args .Google ScholarGoogle Scholar
  19. NSolid. 2015. https://nodesource.com/products/nsolid .Google ScholarGoogle Scholar
  20. 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 ScholarGoogle ScholarCross RefCross Ref
  21. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  22. Promise/A. “Promise/A+ Specification.” 2014. https://promisesaplus. com .Google ScholarGoogle Scholar
  23. New Relic. 2012. https://newrelic.com/nodejs .Google ScholarGoogle Scholar
  24. Stackdriver. 2015. https://cloud.google.com/trace/ .Google ScholarGoogle Scholar
  25. Async Call Stacks. 2014. http://www.html5rocks.com/en/tutorials/ developertools/async-call-stack/ .Google ScholarGoogle Scholar
  26. Zones. 2014. https://github.com/angular/zone.js .Google ScholarGoogle Scholar

Index Terms

  1. Semantics of asynchronous JavaScript

      Recommendations

      Comments

      Login options

      Check if you have access through your login credentials or your institution to get full access on this article.

      Sign in

      Full Access

      • Published in

        cover image ACM SIGPLAN Notices
        ACM SIGPLAN Notices  Volume 52, Issue 11
        DLS '17
        November 2017
        86 pages
        ISSN:0362-1340
        EISSN:1558-1160
        DOI:10.1145/3170472
        Issue’s Table of Contents
        • cover image ACM Conferences
          DLS 2017: Proceedings of the 13th ACM SIGPLAN International Symposium on on Dynamic Languages
          October 2017
          86 pages
          ISBN:9781450355261
          DOI:10.1145/3133841

        Copyright © 2017 Owner/Author

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 24 October 2017

        Check for updates

        Qualifiers

        • article

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader
      About Cookies On This Site

      We use cookies to ensure that we give you the best experience on our website.

      Learn more

      Got it!