Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
research-article
Open access

A model for reasoning about JavaScript promises

Published: 12 October 2017 Publication History

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.

References

[1]
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).
[2]
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).
[3]
Petka Antonov. 2013. bluebird. https://github.com/petkaantonov/bluebird . (2013). Accessed: 2016-10-27.
[4]
ECMA. 2015. 262: ECMAScript Language Specification. European Association for Standardizing Information and Communication Systems (ECMA) (2015).
[5]
Matthias Felleisen, Robert Bruce Findler, and Matthew Flatt. 2009. Semantics Engineering with PLT Redex. The MIT Press.
[6]
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).
[7]
Cormac Flanagan and Matthias Felleisen. 1999. The Semantics of Future and an Application. Journal of Functional Programming (1999).
[8]
Daniel Friedman and David Wise. 1976. The Impact of Applicative Programming on Multiprocessing. In International Conference on Parallel Processing.
[9]
Salvatore Guarnieri and Benjamin Livshits. 2009. GATEKEEPER: Mostly Static Enforcement of Security and Reliability Policies for JavaScript Code. In Proc. 18th Usenix Security Symposium.
[10]
Arjun Guha, Claudiu Saftoiu, and Shriram Krishnamurthi. 2010. The Essence of JavaScript. In Proc. 24th European Conference on Object-oriented Programming (ECOOP).
[11]
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).
[12]
David Van Horn and Matthew Might. 2010. Abstracting Abstract Machines. In Proc. 15th ACM International Conference on Functional Programming (ICFP).
[13]
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).
[14]
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).
[15]
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).
[16]
Simon Holm Jensen, Anders Møller, and Peter Thiemann. 2009. Type Analysis for JavaScript. In Proc. 16th International Static Analysis Symposium (SAS).
[17]
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).
[18]
Kris Kowal. 2010. Q. https://github.com/kriskowal/q . (2010). Accessed: 2016-10-27.
[19]
Magnus Madsen and Esben Andreasen. 2014. String Analysis for Dynamic Field Access. In Proc. 23rd International Conference on Compiler Construction (CC).
[20]
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).
[21]
Magnus Madsen and Anders Møller. 2014. Sparse Dataflow Analysis with Pointers and Reachability. In Proc. 21st International Static Analysis Symposium (SAS).
[22]
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).
[23]
Sergio Maffeis, John C. Mitchell, and Ankur Taly. 2008. An Operational Semantics for JavaScript. In Asian Symposium on Programming Languages and Systems.
[24]
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).
[25]
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).
[26]
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).
[27]
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).
[28]
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).
[29]
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).

Cited By

View all
  • (2024)Latch: Enabling large-scale automated testing on constrained systemsScience of Computer Programming10.1016/j.scico.2024.103157238(103157)Online publication date: Dec-2024
  • (2023)Code Coverage Criteria for Asynchronous ProgramsProceedings of the 31st ACM Joint European Software Engineering Conference and Symposium on the Foundations of Software Engineering10.1145/3611643.3616292(1307-1319)Online publication date: 30-Nov-2023
  • (2023)Typing Composable Coroutines2023 12th International Conference on Computer Technologies and Development (TechDev)10.1109/TechDev61156.2023.00011(16-23)Online publication date: 14-Oct-2023
  • Show More Cited By

Recommendations

Comments

Information & Contributors

Information

Published In

cover image Proceedings of the ACM on Programming Languages
Proceedings of the ACM on Programming Languages  Volume 1, Issue OOPSLA
October 2017
1786 pages
EISSN:2475-1421
DOI:10.1145/3152284
Issue’s Table of Contents
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 12 October 2017
Published in PACMPL Volume 1, Issue OOPSLA

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. EcmaScript 6
  2. Formal Semantics
  3. JavaScript
  4. Promise Graph
  5. Promises

Qualifiers

  • Research-article

Funding Sources

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)362
  • Downloads (Last 6 weeks)23
Reflects downloads up to 04 Oct 2024

Other Metrics

Citations

Cited By

View all
  • (2024)Latch: Enabling large-scale automated testing on constrained systemsScience of Computer Programming10.1016/j.scico.2024.103157238(103157)Online publication date: Dec-2024
  • (2023)Code Coverage Criteria for Asynchronous ProgramsProceedings of the 31st ACM Joint European Software Engineering Conference and Symposium on the Foundations of Software Engineering10.1145/3611643.3616292(1307-1319)Online publication date: 30-Nov-2023
  • (2023)Typing Composable Coroutines2023 12th International Conference on Computer Technologies and Development (TechDev)10.1109/TechDev61156.2023.00011(16-23)Online publication date: 14-Oct-2023
  • (2023)Web accessibility evaluation of private and government websites for people with disabilities through fuzzy classifier in the USASoft Computing10.1007/s00500-023-08740-6Online publication date: 13-Jul-2023
  • (2022)Evaluating Progressive Web App Accessibility for People with DisabilitiesNetwork10.3390/network20200222:2(350-369)Online publication date: 8-Jun-2022
  • (2022)An asynchronous call graph for JavaScriptProceedings of the 44th International Conference on Software Engineering: Software Engineering in Practice10.1145/3510457.3513059(29-30)Online publication date: 21-May-2022
  • (2022)NessieProceedings of the 44th International Conference on Software Engineering10.1145/3510003.3510106(1494-1505)Online publication date: 21-May-2022
  • (2022)DrAsyncProceedings of the 44th International Conference on Software Engineering10.1145/3510003.3510097(774-785)Online publication date: 21-May-2022
  • (2022)Continuous Assessment Analyzer Using DjangoComputational Intelligence in Machine Learning10.1007/978-981-16-8484-5_4(35-43)Online publication date: 3-Mar-2022
  • (2022)What You See Is What You Get: Practical Effect Handlers in Capability-Passing StyleErnst Denert Award for Software Engineering 202010.1007/978-3-030-83128-8_3(15-43)Online publication date: 28-Feb-2022
  • Show More Cited By

View Options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Get Access

Login options

Full Access

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media