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.

Highlights

  • Promises where added to ECMAScript 6 [Ecmascript 2015], the JavaScript standard, in order to provide better support for the asynchrony that arises in user-interfaces, network communication, and non-blocking I/O

  • We report on the implementation of a tool, PromiseKeeper, that automatically constructs promise graphs based on dynamic analysis

  • Our findings show that PromiseKeeper is capable of constructing promise graphs for large and complex applications with acceptable run-time overhead

Read more

Summary

Introduction

Promises where added to ECMAScript 6 [Ecmascript 2015], the JavaScript standard, in order to provide better support for the asynchrony that arises in user-interfaces, network communication, and non-blocking I/O. Such asynchrony has traditionally been implemented using event-driven programming, which leads to awkward nonlinear control flow commonly referred to as łcallback hellž. Event-driven programming provides poor support for error handling, and unless programmers are careful, event-driven programs may experience non-deterministic failures. Lang., Vol 2, No OOPSLA, Article 162.

Objectives
Methods
Results
Conclusion
Full Text
Paper version not known

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call