skip to main content
research-article
Open Access
Artifacts Available
Artifacts Evaluated & Functional

Finding broken promises in asynchronous JavaScript programs

Published:24 October 2018Publication History
Skip Abstract Section

Abstract

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 pitfalls of event-driven programming such as event races and the deeply nested counterintuitive control ow referred to as “callback hell”. Unfortunately, promises have complex semantics and the intricate control– and data- ow present in promise-based code hinders program comprehension and can easily lead to bugs. The promise graph was proposed as a graphical aid for understanding and debugging promise-based code. However, it did not cover all promise-related features in ECMAScript 6, and did not present or evaluate any technique for constructing the promise graphs. In this paper, we extend the notion of promise graphs to include all promise-related features in ECMAScript 6, including default reactions, exceptions, and the synchronization operations race and all. Furthermore, we report on the construction and evaluation of PromiseKeeper, which performs a dynamic analysis to create promise graphs and infer common promise anti-patterns. We evaluate PromiseKeeper by applying it to 12 open source promise-based Node.js applications. Our results suggest that the promise graphs constructed by PromiseKeeper can provide developers with valuable information about occurrences of common anti-patterns in their promise-based code, and that promise graphs can be constructed with acceptable run-time overhead.

Skip Supplemental Material Section

Supplemental Material

a162-alimadadi.webm

References

  1. Christoffer Quist Adamsen, Anders Møller, Rezwana Karim, Manu Sridharan, Frank Tip, and Koushik Sen. 2017b. Repairing Event Race Errors by Controlling Nondeterminism. In Proc. 39th International Conference on Software Engineering (ICSE). Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Christoffer Quist Adamsen, Anders Møller, and Frank Tip. 2017a. Practical Initialization Race Detection for JavaScript Web Applications. In Proc. ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA) .Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Saba Alimadadi, Ali Mesbah, and Karthik Pattabiraman. 2015. Hybrid DOM-Sensitive Change Impact Analysis for JavaScript. In Proceedings of the European Conference on Object-Oriented Programming (ECOOP). LIPIcs, 321–345.Google ScholarGoogle Scholar
  4. Saba Alimadadi, Ali Mesbah, and Karthik Pattabiraman. 2016a. Understanding Asynchronous Interactions in Full-Stack JavaScript. In Proceedings of the ACM/IEEE International Conference on Software Engineering (ICSE). ACM, 1169–1180. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Saba Alimadadi, Ali Mesbah, and Karthik Pattabiraman. 2018. Inferring Hierarchical Motifs from Execution Traces. In Proceedings of the ACM/IEEE International Conference on Software Engineering (ICSE) . ACM, 12 pages. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Saba Alimadadi, Sheldon Sequeira, Ali Mesbah, and Karthik Pattabiraman. 2016b. Understanding JavaScript Event-Based Interactions with Clematis. ACM Transactions on Software Engineering and Methodology (TOSEM) 25, 2 (2016), 38. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Domenico Amalfitano, AnnaRita Fasolino, Armando Polcaro, and Porfirio Tramontana. 2014. The DynaRIA tool for the comprehension of Ajax web applications by dynamic analysis. Innovations in Systems and Software Engineering 10, 1 (2014), 41–57. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Esben Andreasen, Liang Gong, Anders Møller, Michael Pradel, Marija Selakovic, Koushik Sen, and Cristian-Alexandru Staicu. 2017. A Survey of Dynamic Analysis and Test Generation for JavaScript. ACM Computing Surveys (CSUR) 50, 5 (2017), 66. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Earl T. Barr, Mark Marron, Ed Maurer, Dan Moseley, and Gaurav Seth. 2016. Time-travel Debugging for JavaScript/Node.Js. In Proceedings of the 24th ACM SIGSOFT International Symposium on Foundations of Software Engineering (FSE 2016). ACM, 1003–1007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Giuseppe Di Battista, Peter Eades, Roberto Tamassia, and Ioannis G Tollis. 1998. Graph drawing: algorithms for the visualization of graphs . Prentice Hall PTR. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Etienne Brodu, Stéphane Frénot, and Frédéric Oblé. 2015. Toward automatic update from callbacks to Promises. In Proceedings of the 1st Workshop on All-Web Real-Time Systems . ACM, 1. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. ECMA Ecmascript. 2015. Language Specification. (2015).Google ScholarGoogle Scholar
  13. Keheliya Gallaba, Quinn Hanam, Ali Mesbah, and Ivan Beschastnikh. 2017. Refactoring Asynchrony in JavaScript. In Proceedings of the International Conference on Software Maintenance and Evolution (ICSME) . IEEE Computer Society, 11 pages.Google ScholarGoogle ScholarCross RefCross Ref
  14. Erich Gamma. 1995. Design patterns: elements of reusable object-oriented software. Pearson Education India. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Liang Gong, Michael Pradel, Manu Sridharan, and Koushik Sen. 2015. DLint: dynamically checking bad coding practices in JavaScript. In Proceedings of the 2015 International Symposium on Software Testing and Analysis. ACM, 94–105. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Arjun Guha, Claudiu Saftoiu, and Shriram Krishnamurthi. 2010. The essence of JavaScript. In European conference on Object-oriented programming . Springer, 126–150. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Joshua Hibschman and Haoqi Zhang. 2015. Unravel: Rapid Web Application Reverse Engineering via Interaction Recording, Source Tracing, and Library Detection. In Proceedings of ACM User Interface Software and Technology Symposium (UIST). ACM, 270–279. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Simon Holm Jensen, Manu Sridharan, Koushik Sen, and Satish Chandra. 2015. MemInsight: platform-independent memory debugging for JavaScript. In Proceedings of the 2015 10th Joint Meeting on Foundations of Software Engineering. ACM, 345–356. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Kennedy Kambona, Elisa Gonzalez Boix, and Wolfgang De Meuter. 2013. An evaluation of reactive programming and promises for structuring collaborative web applications. In Proceedings of the 7th Workshop on Dynamic Languages and Applications . ACM, 3. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Yit Phang Khoo, Michael Hicks, Jeffrey S Foster, and Vibha Sazawal. 2009. Directing JavaScript with arrows. ACM SIGPLAN Notices 44, 12 (2009), 49–58. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Matthew C Loring, Mark Marron, and Daan Leijen. 2017. Semantics of asynchronous JavaScript. In ACM SIGPLAN Notices, Vol. 52. ACM, 51–62. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Magnus Madsen, Ondřej Lhoták, and Frank Tip. 2017. A Model for Reasoning About JavaScript Promises. In Object-Oriented Programming, Systems, Languages & Applications (OOPSLA) . Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Magnus Madsen, Frank Tip, Esben Andreasen, Koushik Sen, and Anders Møller. 2016. Feedback-directed instrumentation for deployed JavaScript applications. In Software Engineering (ICSE), 2016 IEEE/ACM 38th International Conference on. IEEE, 899–910. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Magnus Madsen, Frank Tip, and Ondřej Lhoták. 2015. Static Analysis of Event-Driven Node.js JavaScript Applications. In Object-Oriented Programming, Systems, Languages & Applications (OOPSLA) . Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Josip Maras, Maja Stula, and Jan Carlson. 2013. Generating Feature Usage Scenarios in Client-side Web Applications. In Proceeding of the International Conference on Web Engineering (ICWE) . Springer, 186–200. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Boris Petrov, Martin Vechev, Manu Sridharan, and Julian Dolby. 2012. Race detection for web applications. In ACM SIGPLAN Notices , Vol. 47. ACM, 251–262. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. PromiseKeeper 2018. PromiseKeeper. https://github.com/nuprl/PromiseKeeper . (2018).Google ScholarGoogle Scholar
  28. Veselin Raychev, Martin Vechev, and Manu Sridharan. 2013. Effective race detection for event-driven programs. In ACM SIGPLAN Notices , Vol. 48. ACM, 151–166. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Koushik Sen, Swaroop Kalasapur, Tasneem Brutch, and Simon Gibbs. 2013. Jalangi: a selective record-replay and dynamic analysis framework for JavaScript. In Proceedings of the 2013 9th Joint Meeting on Foundations of Software Engineering. ACM, 488–498. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Andy Zaidman, Nick Matthijssen, Margaret-Anne Storey, and Arie van Deursen. 2013. Understanding Ajax applications by connecting client and server-side execution traces. Empirical Software Engineering 18, 2 (2013), 181–218. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  32. Yunhui Zheng, Tao Bao, and Xiangyu Zhang. 2011. Statically locating web application bugs caused by asynchronous calls. In Proceedings of the 20th international conference on World wide web. ACM, 805–814. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Finding broken promises in asynchronous JavaScript programs

      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

      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!