Re: [whatwg/dom] Add a way to identify Abort errors originating from controllers (Issue #1033)

I generally agree with @domenic on this, although I might be more convinced about the need with some concrete examples of code that can't access the signal but still needs to observe cancellation.

Being able to identify cancellation from sources you don't have a signal/controller for seem a lot like arbitrary stack inspection, like the fact that an abort controller/signal is even used should generally be transparent to you unless you're actually in a position to observe it. The one possible exception to this is promise-accepting APIs, however these are pretty rare, more often things will take a function which returns a promise in which case you should have an opportunity to pass in an abort signal/controller.

> This is just an example, it can be worked around (by for example making the signal global, injecting the signal to all components) but that would create pretty ugly code from what I recall.

While I do agree with the sentiment, the fact that cancellation had to be done in userland and efforts at TC39 failed, means that wiring abort signals through all functions is just what is neccessary.

I would certainly still like to see some revival of such integration of cancellation, but I'm not sure it's likely to happen. If [function decorators](https://github.com/tc39/proposal-decorators/blob/master/EXTENSIONS.md#function-decorators-and-annotation) happen at some point in future, it may be possible to create such a thing in userland (especially easy if we could get an `await` hook or something in decorators).

This is yet-another place where `Zone`-style functionality would help, because frameworks could create zones that can vend abort controllers/signals associated to the Zone and ensure that errors don't escape. I dunno what happened to the [other proposal](https://github.com/legendecas/proposal-async-context) that added a couple smaller primitives similar to zones, but that sort've functionality would definitely enable such things as well.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/1033#issuecomment-980814451

Received on Sunday, 28 November 2021 00:47:01 UTC