core-js
core-js copied to clipboard
`AbortController` and `AbortSignal`
I searched on the issue tracker and repo but didn't find anything about it, are there any plans to add a polyfill for AbortController and AbortSignal? It's primary purpose is to be able to cancel fetch requests, but can also be used manually as a standard mechanism for cancelling promises or any kind of async behavior.
The final version of AbortController has been added to the DOM specification The corresponding PR for the fetch specification is now merged. Browser bugs tracking the implementation of AbortController is available here: Firefox: #1378342, Chromium: #750599, WebKit: #174980, Edge: #13009916.
Current browser support: https://www.caniuse.com/#feat=abortcontroller
That does not look like something in the scope of core-js
. core-js
about ECMAScript spec and cross-platform related features. For canceling promises, I'm waiting for https://github.com/tc39/proposal-cancellation
Since they have become a de facto standard, I suggest to support them in core-js as well.
FYI: The DOM Standard specification has just been updated (https://github.com/whatwg/dom/pull/1027). It has not yet been implemented on any platform except Deno.
I wanted to reopen this discussion a little later.
It may be helpful to refer to WinterCG's Minimum Common Web Platform API.
...and this post. Ok, let's reopen this issue.
It is the scope of core-web
: https://github.com/aleen42/core-web/commit/651d3ba271402d862e70a385df239ebfeea9895d
@aleen42 thanks, maybe it will be possible to reuse something from that.
I hacked together a basic polyfill for AbortController/AbortSignal at https://github.com/CaptainPants/zerodeps-multipart-parser/blob/main/src/polyfills/abort.ts. I haven't spent a lot of time on spec compliance, but it might be worth something to the project.
AbortSignal.any
is probably difficult to implement because it requires iterable weak sets (WeakSet
+ WeakRef
) in spec
https://github.com/whatwg/dom/pull/1152
@petamoriken I have not delved into the features and the specification of this API, but at first glance, it looks like a simple combinator like Promise.any
, so I don't see why it's required. Could you explain?
Ok, I looked at the PR that you mentioned and see what you mean. It's bad, but I don't think that it's a critical problem if in the case of the existence of WeakRef
we will have proper garbage collecting of listeners here and in the case of old engines - leaks.