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

Show parent comments

0

u/[deleted] Oct 11 '17

[deleted]

2

u/alexelcu Oct 11 '17

In the article I'm linking to my implementation, using what is a standard solution (I do not claim credit), with results that should be easily reproducible (under 5 minutes).

But to your assertion:

  1. Scala's standard Future does not leak

  2. Twitter's Future does not leak

  3. Bluebird I've been told doesn't leak either, being known to be implemented differently

Also in the article I'm linking to the issues created on Node's the Spec's repositories.

You can build one in Java too. Here's Trane.io, built by a Twitter engineer and an acquaintance of mine, although this one comes with a twist - for tail recursivity, you have to defer the thing with a TailRec object, but that choice was made specifically for performance reasons.

0

u/[deleted] Oct 11 '17

[deleted]

2

u/alexelcu Oct 11 '17

perestroika12, how can I say this?

I mentioned 4 independent implementations used at scale, one of them being Twitter's. None of them have the behavior mentioned.

endless future chain

No, it's creating a loop and we are talking about tail call optimizations for these asynchronous then calls. The "endless future chain" is the problem, because it should not happen.

you have a fundamental misunderstanding of why this is happening and what is going on

I've built Monix, which contains an innovative Haskell IO port, one of the best in existence actually, along with what I believe to be the best back-pressured Rx Observable implementation. A cancellable future is also in there.

Following that, I've built Funfix, which contains IO, Eval and Future, all of which are memory safe. I'm mentioning this in the article, being the reason for why I wrote the article — because I've actually understood the problem and the fix.

And I've helped with cats-effect, being a contributor to cats as well.

If you'll notice there's a pattern in my work, but good or bad, you can't accuse me of a fundamental misunderstanding of what's going on, given that I've implementing the thing multiple times already, with different capabilities and made great effort to work around the problem — which in my case is actually more difficult, because my stuff is also cancelable.