Abstract
In JavaScript programs, asynchrony arises in situations such as web-based user-interfaces, communicating with servers through HTTP requests, and non-blocking I/O. Event-based programming is the most popular approach for managing asynchrony, but suffers from problems such as lost events and event races, and results in code that is hard to understand and debug. Recently, ECMAScript 6 has added support for promises, an alternative mechanism for managing asynchrony that enables programmers to chain asynchronous computations while supporting proper error handling. However, promises are complex and error-prone in their own right, so programmers would benefit from techniques that can reason about the correctness of promise-based code.
Since the ECMAScript 6 specification is informal and intended for implementers of JavaScript engines, it does not provide a suitable basis for formal reasoning. This paper presents λp, a core calculus that captures the essence of ECMAScript 6 promises. Based on λp, we introduce the promise graph, a program representation that can assist programmers with debugging of promise-based code. We then report on a case study in which we investigate how the promise graph can be helpful for debugging errors related to promises in code fragments posted to the StackOverflow website.
- Christoffer Quist Adamsen, Anders Møller, Rezwana Karim, Manu Sridharan, Frank Tip, and Koushik Sen. 2017. Repairing Event Race Errors by Controlling Nondeterminism. In Proc. 39th International Conference on Software Engineering (ICSE). Google Scholar
Digital Library
- Esben Andreasen and Anders Møller. 2014. Determinacy in static analysis for jQuery. In Proc. 29th ACM SIGPLAN International Conference on Object Oriented Programming Systems Languages, and Applications (OOPSLA). Google Scholar
Digital Library
- Petka Antonov. 2013. bluebird. https://github.com/petkaantonov/bluebird . (2013). Accessed: 2016-10-27.Google Scholar
- ECMA. 2015. 262: ECMAScript Language Specification. European Association for Standardizing Information and Communication Systems (ECMA) (2015).Google Scholar
- Matthias Felleisen, Robert Bruce Findler, and Matthew Flatt. 2009. Semantics Engineering with PLT Redex. The MIT Press.Google Scholar
Digital Library
- Cormac Flanagan and Matthias Felleisen. 1995. The Semantics of Future and its use in Program Optimization. In Proc. 22nd ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI). Google Scholar
Digital Library
- Cormac Flanagan and Matthias Felleisen. 1999. The Semantics of Future and an Application. Journal of Functional Programming (1999).Google Scholar
- Daniel Friedman and David Wise. 1976. The Impact of Applicative Programming on Multiprocessing. In International Conference on Parallel Processing.Google Scholar
- Salvatore Guarnieri and Benjamin Livshits. 2009. GATEKEEPER: Mostly Static Enforcement of Security and Reliability Policies for JavaScript Code. In Proc. 18th Usenix Security Symposium.Google Scholar
- Arjun Guha, Claudiu Saftoiu, and Shriram Krishnamurthi. 2010. The Essence of JavaScript. In Proc. 24th European Conference on Object-oriented Programming (ECOOP). Google Scholar
Cross Ref
- Shin Hong, Yongbae Park, and Moonzoo Kim. 2014. Detecting Concurrency Errors in Client-Side Java Script Web Applications. In Proc. 7th IEEE International Conference on Software Testing, Verification and Validation (ICST). Google Scholar
Digital Library
- David Van Horn and Matthew Might. 2010. Abstracting Abstract Machines. In Proc. 15th ACM International Conference on Functional Programming (ICFP). Google Scholar
Digital Library
- Casper Svenning Jensen, Anders Møller, Veselin Raychev, Dimitar Dimitrov, and Martin T. Vechev. 2015. Stateless Model Checking of Event-Driven Applications. In Proc. 30th ACM SIGPLAN International Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA). Google Scholar
Digital Library
- Simon Holm Jensen, Peter Jonsson, and Anders Møller. 2012. Remedying the Eval That Men Do. In Proc. International Symposium on Software Testing and Analysis (ISSTA). Google Scholar
Digital Library
- Simon Holm Jensen, Magnus Madsen, and Anders Møller. 2011. Modeling the HTML DOM and Browser API in Static Analysis of JavaScript Web Applications. In Proc. 8th joint meeting of the European Software Engineering Conference and the ACM SIGSOFT Symposium on the Foundations of Software Engineering (ESEC/FSE). Google Scholar
Digital Library
- Simon Holm Jensen, Anders Møller, and Peter Thiemann. 2009. Type Analysis for JavaScript. In Proc. 16th International Static Analysis Symposium (SAS). Google Scholar
Digital Library
- Vineeth Kashyap, Kyle Dewey, Ethan Kuefner, John Wagner, Kevin Gibbons, John Sarracino, Ben Wiedermann, and Ben Hardekopf. 2014. JSAI: A Static Analysis Platform for JavaScript. In Proc. 22nd ACM SIGSOFT International Symposium on Foundations of Software Engineering (FSE).Google Scholar
Digital Library
- Kris Kowal. 2010. Q. https://github.com/kriskowal/q . (2010). Accessed: 2016-10-27.Google Scholar
- Magnus Madsen and Esben Andreasen. 2014. String Analysis for Dynamic Field Access. In Proc. 23rd International Conference on Compiler Construction (CC). Google Scholar
Cross Ref
- Magnus Madsen, Benjamin Livshits, and Michael Fanning. 2013. Practical Static Analysis of JavaScript Applications in the Presence of Frameworks and Libraries. In Proc. European Software Engineering Conference and the Symposium on the Foundations of Software Engineering (ESEC/FSE). Google Scholar
Digital Library
- Magnus Madsen and Anders Møller. 2014. Sparse Dataflow Analysis with Pointers and Reachability. In Proc. 21st International Static Analysis Symposium (SAS). Google Scholar
Cross Ref
- Magnus Madsen, Frank Tip, and Ondřej Lhoták. 2015. Static Analysis of Event-driven Node.Js JavaScript Applications. In Proc. ACM SIGPLAN International Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA).Google Scholar
Digital Library
- Sergio Maffeis, John C. Mitchell, and Ankur Taly. 2008. An Operational Semantics for JavaScript. In Asian Symposium on Programming Languages and Systems. Google Scholar
Digital Library
- Erdal Mutlu, Serdar Tasiran, and Benjamin Livshits. 2015. Detecting JavaScript Races that Matter. In Proc. 10th Joint Meeting on Foundations of Software Engineering (ESEC/FSE). Google Scholar
Digital Library
- Boris Petrov, Martin T. Vechev, Manu Sridharan, and Julian Dolby. 2012. Race Detection for Web Applications. In Proc. 33rd ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI). Google Scholar
Digital Library
- Veselin Raychev, Martin T. Vechev, and Manu Sridharan. 2013. Effective Race Detection for Event-Driven Programs. In Proc. 28th ACM SIGPLAN International Conference on Object Oriented Programming Systems Languages, and Applications (OOPSLA). Google Scholar
Digital Library
- Adam Welc, Suresh Jagannathan, and Antony Hosking. 2005. Safe Futures for Java. Proc. 20th ACM SIGPLAN International Conference on Object Oriented Programming Systems Languages, and Applications (OOPSLA) (2005). Google Scholar
Digital Library
- Lu Zhang and Chao Wang. 2017. RClassify: Classifying Race Conditions in Web Applications via Deterministic Replay. In Proc. 39th International Conference on Software Engineering (ICSE). Google Scholar
Digital Library
- Yunhui Zheng, Tao Bao, and Xiangyu Zhang. 2011. Statically Locating Web Application Bugs Caused by Asynchronous Calls. In Proc. 20th International Conference on World Wide Web (WWW). Google Scholar
Digital Library
Index Terms
A model for reasoning about JavaScript promises
Recommendations
Finding broken promises in asynchronous JavaScript programs
Recently, promises were added to ECMAScript 6, the JavaScript standard, in order to provide better support for the asynchrony that arises in user interfaces, network communication, and non-blocking I/O. Using promises, programmers can avoid common ...






Comments