Comments (4)
This would imply swapping following code path:
Lines 147 to 151 in 61c7fe2
with something along the lines of
from js-ipfs-utils.
Reopening this issue as it had to be reverted #58, as it broke pub / sub.
from js-ipfs-utils.
Moving some of the conversation from #54 here
From @achingbrain
I think we might have to revert this - the upload/download progress handlers are useful but XHR has no way of doing streaming downloads so it's broken pubsub in the browser as it works via long-lived requests and the call to make the request doesn't return until the load event occurs, eg. the request has finished.
Sorry for the complications, I was not aware of this.
You can access partially loaded content via the .responseText property when .readyState === 3, but only when the response type is text which breaks when the response is non-printable binary data and .responseText grows over time causing a memory leak so it's not much of a solution.
That is how we used to do that back in pre-fetch days. However since I imagine on pubsub response body to be unbound, it's probably not going to be viable option.
@Gozala any ideas on this?
From the sound of it, we only care about streaming body on pubsub, in all other cases getting body via XHR seems reasonable. Therefor instead of trying to workaround XHR, we could probably have an option to choose between progress events and streaming response. That way pubsub can continue using fetch and file upload can opt-in into XHR via progress events. Added complexity is unfortunate, but I don't think there is anything better we can until ReadableStream
's as request bodies are supported by browsers.
from js-ipfs-utils.
@achingbrain what do you think about using XHR
if options.onUploadProgress
or options.onDownloadProgress
is provided, otherwise use fetch
?
from js-ipfs-utils.
Related Issues (20)
- native-fetch types are made up
- auto-installing peerDependencies in npm@7 means `ipfs-utils` installs `react-native` everywhere. HOT 2
- Defer to native-fetch whenever `ELECTRON_RUN_AS_NODE` is set HOT 7
- node-fetch missing in the dependency list HOT 3
- fetch and http requests HOT 5
- Custom node-fetch causes builds to fail HOT 4
- `electron-fetch` dependency is not ESM compatible HOT 1
- TypeScript declarations broken in 9.0.4 HOT 5
- Unable to import ipfs-http-client due to ipfs-utils using require statement HOT 3
- unable to run in functions because of use of 'fs' HOT 2
- How can i build es Modules with rollup ? HOT 2
- Problem when importing fetch in new version of native-fetch HOT 2
- npm install failed HOT 3
- TypeError: RequestInit: duplex option is required when sending a body. HOT 2
- Convert to ESM HOT 2
- Bug: Too much event listeners attached to an AbortSignal HOT 4
- Error related to fetch.js and Webpack HOT 13
- NodeJS and Electron conflict HOT 4
- HTTPOptions body type does not allow FormData HOT 2
- Building docs fails during release HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from js-ipfs-utils.