Fetch: Implement abort

Created on 26 Jul 2017  路  6Comments  路  Source: github/fetch

As per https://github.com/whatwg/fetch/pull/523

I guess it should wait till the above is merged.

Most helpful comment

I quite dig the polyfill that @jimmywarting shared. Does anyone think that this project should include that kind of polyfill? Should we try to patch native window.fetch if it doesn't support aborting?

All 6 comments

just a reference: https://github.com/mo/abortcontroller-polyfill/blob/master/src/abortcontroller.js#L8-L47
this will patch fetch and return a rejection instead, it dosen't abort the fetch

@lukeapage @mislav whatwg/fetch#523 just got merged

Yep, I've been following. Good news.

I quite dig the polyfill that @jimmywarting shared. Does anyone think that this project should include that kind of polyfill? Should we try to patch native window.fetch if it doesn't support aborting?

You should try calling xhr.abort to not wast bandwidth

I agree with @mislav 's and @jimmywarting 's suggestions over in #572 that keeping the AbortController and AbortSignal polyfills separate from this library seems preferable.

Should we try to patch native window.fetch if it doesn't support aborting?

I think so. You may already be thinking this, but it would probably be a breaking change to the API, as this library would start polyfilling many more apps than it currently does. This might warrant a major version bump if this lib follows semver.

You should try calling xhr.abort to not wast bandwidth

It would be pretty cool to see this library update to accept a (duck-typed) AbortSignal and call xhr.abort whenever the abort event is dispatched.

A quick glance at the code suggests to me that this should be straightforward to implement. Perhaps the hardest part will be updating the feature detection code.

I wrote a quick snippet that seems like a step in the right direction. I tested it in Safari, Chrome, and Firefox, and got the expected results (no, no, yes, respectively).

What do folks think? Should I code up a PR that implements something along these lines? PR'd at #592

Was this page helpful?
0 / 5 - 0 ratings

Related issues

seekcx picture seekcx  路  4Comments

codeashian picture codeashian  路  3Comments

hannesvdvreken picture hannesvdvreken  路  4Comments

proofrock picture proofrock  路  3Comments

mmocny picture mmocny  路  3Comments