The problem with infinite recursive promise resolution chains
At this point in the chapter, you should have a strong understanding of how promises work and how to use them to implement the most common control flow constructs. This is the right time to discuss an advanced topic that every professional Node.js developer should know and understand. This advanced topic is about a memory leak caused by infinite Promise
resolution chains. The bug affects the actual Promises/A+ specification, so no compliant implementation is immune.
It is quite common in programming to have tasks that don’t have a predefined ending or take as an input a potentially infinite array of data. We can include in this category things such as the encoding/decoding of live audio/video streams, the processing of live cryptocurrency market data, and the monitoring of IoT sensors. But you don’t need such complex scenarios to run into the same challenges. In fact, these situations can arise even in...