Live data from Hacker News

You can't cancel a JavaScript promise (except sometimes you can)

inngest.com

61–66 of 66 posts

Re: You can't cancel a JavaScript promise (except sometimes you can)

#61
post #57

Earlier quoted context omitted.

Browsers have said that they are unwilling to ship any new cancelation mechanisms given that AbortSignal already exists, so we can't ship a different CancelToken. But I think there's a path to standardizing a subset of the existing AbortSignal machinery [1]. (I am on TC39 and while this isn't my highest priority I did bring the topic for discussion at the last meeting [2], and there was support from the rest of commi…

Yes, I was around during the original discussions. AbortSignal exists because TC39 was taking too long and cancelling fetch() is table stakes for a networking oriented platform like the web. Those threads are a good example of what's wrong in TC39. A simple AbortSignal could have been added, but by the time it's reconciled with SES, large speculative APIs like Governers, or the original attempt to add a parallel thro…

I agree that the original cancellation discussion was bad. I don't agree that these threads reflect the same disfunction. They're a new effort (from me). No one was working on it previously because browsers have said that they were unwilling to add any other form of cancellation given that AbortSignal already exists, so there was never a chance to add a separate CancelToken once it shipped. The work to be done now is basically administrative: moving a subset from the WHATWG spec to TC39. This has ~no relevance to user's lives unless they're using a JS runtime which does not implement the WinterTC spec, which is approximately no one. The delay has nothing to do with SES (which has no bearing on this), and Governors are a _use case_ which motivates bringing it into the language, not a thing with which it needs to be reconciled.

Re: You can't cancel a JavaScript promise (except sometimes you can)

#63
post #6

I like how C# handles this. You're not forced to support cancellation, but it's strongly encouraged. The APIs all take a CancellationToken, which is driven by a CancellationTokenSource from the ultimate caller. This can then either be manually checked, or when you call a library API it will notice and throw an OperationCancelledException. Edit: note that there is a "wrong" way to do this as well. The Java thread libr…

I was always surprised that Python, of all languages, didn’t support a robust Thread.stop.

Before the removal of the GIL in recent years, Python seemed well-positioned to leverage the GIL to offer safe thread-cancellation points that didn’t leave interpreter internals in a corrupted state.

That’s not necessarily an endorsement of the idea of Thread.stop in many cases, since stopped user code can cause broken assumptions at a high level no matter what, but it has its uses. Erlang’s exit/2 is proof of that, though it is a very sharp and rarely-appropriate tool.

Re: You can't cancel a JavaScript promise (except sometimes you can)

#64
post #6

I like how C# handles this. You're not forced to support cancellation, but it's strongly encouraged. The APIs all take a CancellationToken, which is driven by a CancellationTokenSource from the ultimate caller. This can then either be manually checked, or when you call a library API it will notice and throw an OperationCancelledException. Edit: note that there is a "wrong" way to do this as well. The Java thread libr…

I much prefer Coroutines in Kotlin... Lightweight, pauseable, resumable, cancelable and easy to use without having to provide a CancellationToken AND a CancellationTokenProvider.

I really hope that coroutines land in Rust after being experimental to improve the async stuff.

The C# Tasks are not bad but I think the API could be easier and more precise/clear.

Re: You can't cancel a JavaScript promise (except sometimes you can)

#65

Earlier quoted context omitted.

Mh, I couldn't read due to the huge contrast and had to switch to reader mode, so...

What colors were you seeing? It's light white text on a black background for me-- both super common and plenty readable.

yeah same. It gives me a bit of a halo effect on letters, making it much harder to read (even w glasses). My astigmatism is pretty light and I wear glasses but it's still difficult to read for me

Re: You can't cancel a JavaScript promise (except sometimes you can)

#66

Earlier quoted context omitted.

Mh, I couldn't read due to the huge contrast and had to switch to reader mode, so...

I personally find it to be perfectly readable. I've heard of people with issues with white text on a black background, but I don't fully understand it. Do you have astigmatism?

I do, although my astigmatism is pretty light and I wear glasses for it
Post reply on HN