In this answer, a promise chain is built recursively.
Simplified slightly, we have :
function foo() {
function doo() {
// always return a promise
if (/* more to do */) {
return doSomethingAsync().then(doo);
} else {
return Promise.resolve();
}
}
return doo(); // returns a promise
}
Presumably this would give rise to a call stack and a promise chain - ie deep and wide.
I would anticipate a memory spike larger than either performing a recursion or building a promise chain alone.
- Is this so?
- Has anyone considered the memory issues of building a chain in this way?
- Would memory consumption differ between promise libs?