-
Notifications
You must be signed in to change notification settings - Fork 30
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
Progress events without breaking pub-sub #60
Conversation
Electron seems to be failing because we use native fetch there, while we're passing non native I have added |
Now this got complicated. It looks like http module makes use of any-singnal which in turn uses Not sure what's the best thing to do here is. I have created mysticatea/abort-controller#24 |
I would really like to avoid #52 #54 #57 and this one by doing nothing or at best implement download progress (which can be done using fetch). Upload progress is and always was a dream thats why browsers never implemented it (or streams) any box between client and origin server can buffer the request and the progress means nothing. Hopefully in the future this will change (chrome is already implementing streams but warns about this problem). Sorry for not supporting this, lots of good work went into making this, but i really think its best not to increase complexity for the upload progress. This is just my opinion if others support this i will not block it. |
The main motivation here is to support upload progress in webui. Adding a large file takes a long enough that webui appears broken. E.g. 2gig file takes 10-12secs (for more details and numbers see ipfs/ipfs-webui#1534) With this changes it was possible to render fairly accurate progrssbar. Your comment about box between server and client is correct, but it does not apply to the problem we were trying to solve, because webui talks to the local node. I personally do not think that waiting on chrome to ship request streams, then waiting for it to propagate to the electron and giving up on non-chromium browsers in order to reduced complexity is the right tradeoff, because it leaves wrong impression of the IPFS ecosystem when someone is just trying to add a file. However there might be alternative ways we could consider to provide a feedback, e.g. infinite spinners. They do help a bit, but don't really work for long tasks that take 10secs. |
I think the UX improvement this adds outweighs the additional complexity. We should add some additional tests here to catch regressions. @Gozala can we add some tests to validate this actually fixes the streaming issue we had with pubsub? While I did run this branch against js-ipfs previously and the tests passed, we shouldn't need to rely on that suite to verify things are working as expected. |
I agree with @Gozala on this, shifting burden from the library to its user feels like a bad trade off here. We document :+1 on adding tests for:
|
This is the wrong solution as it ignores what's actually going during the API call (e.g. the HTTP request and the API request may have different notions of 'progress'), but sadly the right solution is completely impractical right now (bidirectional HTTP streaming in browsers) so it'll have to do. Can you also please:
|
If you are in the Electron Renderer process, native fetch is available but it's ignored because the renderer does not respect the browser field of package.json, so we end up with node-fetch that uses a browser polyfill of the node http api. Instead use native fetch if it's available or node fetch if not.
c244679
to
19fccc6
Compare
I added jsdoc comment but have not added it the README, because I don't think we want users to pass this option as it would disable streaming. It is only used by
Verified |
Had to reset on top of current master, otherwise github complained about non-clean merge even though I did merge master in 🤷♂️ |
merged #62 into this as there was some overlap between two |
Can you fix the conflicts please? Then we should try to get this resolved. |
So #62 has introduced @achingbrain/electron-fetch as a dependency, which is API incompatible with both node-fetch and native fetch 😭, more specifically native and a Which causes them to be treated as strings leading to incorrect behavior here: js-ipfs-utils/src/http/fetch.node.js Lines 82 to 99 in 8111a80
Furthermore unlike node-fetch electron-fetch represents What's worth both seem to ignore that |
@achingbrain I've update patch so that it overcomes issues mentioned in last comment. While it would make sense to make changes to electron-fetch to make it more API compatible with node-fetch, I would really really like to avoid blocking this further, and pursue that separately. This is already several degrees separated from the actual task of having a progress bar when you import files in webui. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As long, we have tests that guard against regressions (see comment inline), lgtm!
@achingbrain we need this to unblock improved import UX scheduled to land as part of pinning service integration:
// Note: Need to use `arraybuffer` here instead of `blob` because `Blob` | ||
// instances coming from JSDOM are not compatible with `Response` from | ||
// node-fetch (which is the setup we get when testing with jest because | ||
// it uses JSDOM which does not provide a global fetch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this really necessary? We don't use jest and this file should only be used in the browser which wouldn't be using node-fetch
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You told me in the earlier comment to:
Ensure it doesn't cause a regression for ipfs/js-ipfs#3238
Which is why this done here.
@achingbrain can you please let me know what else needs to be done here ? |
@hugomrdias could you eyeball these changes and release if you're happy with them please? |
Sure I will do it asap.
Hugo Dias
…On Fri, Nov 13, 2020, 13:57 Alex Potsides ***@***.***> wrote:
@hugomrdias <https://github.com/hugomrdias> could you eyeball these
changes and release if you're happy with them please?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#60 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACMWTXHSN5J7WYNK2LN6GDSPU3OFANCNFSM4QCOMJPA>
.
|
This is second take on #52, which end up breaking pubsub. It is based on #57 which fixed another issue.
With this changes
fetch
will use XHR if eitheroptions.onDownloadProgress
oroptions.onUploadProgress
is provided. Otherwise it will stick to nativefetch
. This wayfile.add
could opt-in into observing progress, but have all of response be buffered before ability to consume it. Pubsub on the other hand doesn't really care about progress events and therefor will continue usingfetch
that can have a streaming response body.