Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Cancellable api request #2862

Closed
MichaelMure opened this issue Feb 17, 2018 · 3 comments
Closed

Cancellable api request #2862

MichaelMure opened this issue Feb 17, 2018 · 3 comments
Labels
exp/wizard Extensive knowledge (implications, ramifications) required kind/feature pkg:http-client Issues related only to ipfs-http-client

Comments

@MichaelMure
Copy link
Contributor

Hi,

Is there a way to cancel a request ?

In particular, I'm doing some ipfs pin add to trigger a download but the request stay active until completion. There is cases where I no longer want to complete the download. How can I do that ?

Thank you

@daviddias
Copy link
Member

To have that, we would need cancellable requests which are not supported by the Fetch API (xhr can cancel, but doesn't support streams) and/or evolve our HTTP API as proposed in https://github.com/ipfs/http-api-spec/issues/116.

@MichaelMure
Copy link
Contributor Author

For the next guy:

  • for node, js-ipfs-api use node's http(s) api which is cancellable (https://nodejs.org/api/http.html#http_request_abort)
  • for the browser, js-ipfs-api use stream-http: which is also cancellable and claim to support "true-streaming" for chrome and "pseudo-streaming" with a good browser coverage

The following browsers support pseudo-streaming, where the data is available before the request finishes, but the entire response must be held in memory:
Chrome
Safari >= 5, and maybe older
IE >= 10
Most other Webkit-based browsers, including the default Android browser

The problem is that if you want to have cancellable request, http-streaming will not use fetch and will fallback to other methods (depending on browser) which may or may not support streams.

That said, cancel support could be added for node, no ?

@achingbrain achingbrain transferred this issue from ipfs-inactive/js-ipfs-http-client Mar 9, 2020
@achingbrain achingbrain added exp/wizard Extensive knowledge (implications, ramifications) required kind/feature pkg:http-client Issues related only to ipfs-http-client labels Mar 9, 2020
@hugomrdias
Copy link
Member

This PR #2993 adds this feature.

🙏 Thank you for your input.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
exp/wizard Extensive knowledge (implications, ramifications) required kind/feature pkg:http-client Issues related only to ipfs-http-client
Projects
None yet
Development

No branches or pull requests

4 participants