r/javascript • • Oct 11 '17

JavaScript's Promise is Memory Unsafe

https://alexn.org/blog/2017/10/11/javascript-promise-memory-unsafe.html
70 Upvotes

77 comments sorted by

View all comments

6

u/[deleted] Oct 11 '17

This is the expected behavior.

This line means the promise can never be released.

loop(0).catch(console.error)

The catch refers to the first promised returned from the loop. That promise "wraps" any subsequent promises that are generated. Every promise in that chain must be kept in order to properly catch the originally returned promise.

In other news, stack exceptions are also Javascript's fault.