Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AbortController and AbortSignal #445

Open
HeberLZ opened this issue Oct 23, 2018 · 11 comments
Open

AbortController and AbortSignal #445

HeberLZ opened this issue Oct 23, 2018 · 11 comments

Comments

@HeberLZ
Copy link

HeberLZ commented Oct 23, 2018

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

@zloirock
Copy link
Owner

zloirock commented Nov 13, 2018

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

@petamoriken
Copy link
Contributor

petamoriken commented Nov 8, 2021

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 (whatwg/dom#1027). It has not yet been implemented on any platform except Deno.

@zloirock
Copy link
Owner

zloirock commented Nov 8, 2021

I wanted to reopen this discussion a little later.

@petamoriken
Copy link
Contributor

It may be helpful to refer to WinterCG's Minimum Common Web Platform API.

@zloirock
Copy link
Owner

...and this post. Ok, let's reopen this issue.

@aleen42
Copy link
Contributor

aleen42 commented Feb 16, 2023

It is the scope of core-web: aleen42/core-web@651d3ba

@zloirock
Copy link
Owner

@aleen42 thanks, maybe it will be possible to reuse something from that.

@CaptainPants
Copy link

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.

@petamoriken
Copy link
Contributor

AbortSignal.any is probably difficult to implement because it requires iterable weak sets (WeakSet + WeakRef) in spec

whatwg/dom#1152

@zloirock
Copy link
Owner

@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?

@zloirock
Copy link
Owner

zloirock commented Nov 18, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants