Re: [whatwg/dom] AbortController.prototype.timeout and AbortController.prototype.cancel (Issue #1039)

I think close()/closed still raises some tricky questions.

- What are the actual use cases? The original post does not mention any for `cancel()`, just for `timeout()`.
- This is one of very few "manual resource management" operations in the web platform, and the first that is not tied to a large chunk of binary data. (Others I can think of are `Blob`/`File`, `URL.revokeObjectURL()`, and `ImageBitmap`.) Is this a reasonable precedent to set? Do we want to encourage a coding style that sprinkles `close()` calls throughout, like a C-style `free()`?
- If this is largely a primitive for implementing follow, we should consider instead doing follow (#920) directly.
- This would be the first bit of `AbortSignal` that is not implementable in "userland", i.e. it requires the ability to remove all listeners. Is that OK? Or should we perhaps expose the primitive in https://github.com/whatwg/dom/issues/412 first?
  - On the other hand, exposing that primitive would go further than `abortController.close()` does, since it would be available to anyone who has a reference to the _signal_, not just the _controller_. We'd need some kind of thing where only the creator of the `EventTarget` has the ability to get or remove all listeners, to give this kind of separation.
  - On the third hand, this kind of worry about leaking event listeners is common for every `EventTarget`; there's nothing really special about `AbortSignal`.
- Is it OK that you can add `abort` listeners after closing? They won't be triggered by `abort()` (since `abort()` is a no-op after closing in the proposal), but they still exist.
- This further increases the division between spec "abort algorithms" and JavaScript `abort` listeners, since spec abort algorithms (including follow) have no effect on closed abort signals, but `abort` listeners still are present and can still be triggered. I and others have protested against this division before; although @annevk was not sympathetic, I hesitate to widen the gap.


-- 
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/1039#issuecomment-989270600

Received on Wednesday, 8 December 2021 22:15:11 UTC