Closed pimterry closed 6 years ago
Would gladly accept and merge it. Thanks!
On Wed, 4 Jul 2018, 15:27 Tim Perry, notifications@github.com wrote:
AbortController is the new standard way to cancel a running fetch request. It's got about 60% support already ( https://caniuse.com/#feat=abortcontroller), but it doesn't work when fetching with this library, even in some browsers that do support it, because of the XHR transport.
Being able to cancel long-running requests is a super useful feature imo, especially when streaming. Would you be interested in a PR that adds support for AbortController to XHR-transported requests too? https://github.com/mo/abortcontroller-polyfill/blob/master/src/abortableFetch.js is a good example of how to patch Fetch to support this in environments where it doesn't, and it's fairly simple. Afaict it's basically just:
- If you pass a signal argument, check signal.aborted, and don't send anything if it's set initially.
- Subscribe to abort events from the signal object.
- Any time a request is aborted, cancel the underlying request, and reject its promises with an AbortError.
Interested? I'd be happy to help out with a PR, if it's likely to be accepted.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jonnyreeves/fetch-readablestream/issues/6, or mute the thread https://github.com/notifications/unsubscribe-auth/AAMN-d2SVUOIB5CKa7-UKpz9l4erAp5fks5uDNDMgaJpZM4VCrQN .
AbortController is the new standard way to cancel a running fetch request. It's got about 60% support already (https://caniuse.com/#feat=abortcontroller), but it doesn't work when fetching with this library, even in some browsers that do support it, because of the XHR transport.
Being able to cancel long-running requests is a super useful feature imo, especially when streaming. Would you be interested in a PR that adds support for AbortController to XHR-transported requests too? https://github.com/mo/abortcontroller-polyfill/blob/master/src/abortableFetch.js is a good example of how to patch Fetch to support this in environments where it doesn't, and it's fairly simple. Afaict it's basically just:
signal
argument, checksignal.aborted
, and don't send anything if it's set initially.abort
events from the signal object.AbortError
.Interested? I'd be happy to help out with a PR, if it's likely to be accepted.