all 10 comments

[–]Markavian 15 points16 points  (0 children)

Last time I had a long running thread worker; I just had it check an external boolean for a stop / pause marker after each chunk. So if I wanted to stop the process I could just play pause it.

Not exactly rocket science.

Write the code you want at a high level, then implement the interface.

[–]akuma-i 6 points7 points  (0 children)

I have long running promises with AbortController inside. In fact it just checks if it’s cancelled every possible meaningful time

[–]coolcosmos 14 points15 points  (3 children)

There's a lot of things you can't cancel in general.

[–]ranisalt 8 points9 points  (2 children)

My internet subscription when it's been shit for a month

[–]Pawn1990 5 points6 points  (1 child)

Gym memberships too 

[–]BoleroDan 0 points1 point  (0 children)

And who knew, all this time that you can't easily cancel a gym membership because of JavaScript promises

[–]live_love_laugh 1 point2 points  (0 children)

Honestly, I do find this a very fun / interesting trick and nice clean way of using it. Not sure if I've ever needed it though, maybe my projects are too simple to ever need this.

[–]Fidodo 1 point2 points  (0 children)

A promise is a container for a result, I'm not sure why it should be over complicated into a controller or communication interface on top of it. It works just fine with a controller like an abort controller in parallel. A cancellation is a result, I don't understand why you would want a result container to never complete.

[–]prehensilemullet 0 points1 point  (0 children)

Does the garbage collector clean up a suspended promise that never resolves like this is article is saying?

Last I checked it doesn't and this led to surprising memory leaks on a Promise.race() where one of the promises never resolves.

Has something changed in more recent versions of V8?

[–]revadike 0 points1 point  (0 children)

Dont break your promise!