OMG TIL: When you use new Promise(resolve => ...), after you call resolve(foo), as you know, resolve is a no-op. Further calls do nothing. You'd think, therefore, also, that holding a reference to resolve long-term doesn't really hold onto anything, because it's a no-op function, why would it be holding onto anything?
Well it turns out, in fact, it holds a reference to the `Promise`, which in turn holds the resolved value, `foo`. So the value `foo` leaks if you never discard `resolve`.
This could obviously be fixed by having resolve null itself out after the first call. But the spec is extremely prescriptive of the exact algorithm here, and it doesn't explicitly say to null out the resolver after it is used, so none of the implementations do it.
And so, if you hold onto a resolve function after calling it, you are leaking memory.
Fun additional fact: Say you do `Promise.race([foo, bar])`. Say that you do this many times, with many different promises for `foo` that resolve promptly, but `bar` never resolves. Maybe `bar` is some sort of global shutdown signal.
Well, in this case, every single resolution of the `foo` promise gets attached to the persistent `bar` promise. They all leak, until `bar` finally resolves.
WTF!?!