-
Notifications
You must be signed in to change notification settings - Fork 299
Handle case where ky responses have no body with a getter for a ReadableStream #1224
base: master
Are you sure you want to change the base?
Handle case where ky responses have no body with a getter for a ReadableStream #1224
Conversation
The basic approach Hugo and I discussed for this PR was to pass the entire |
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.
Thanks for this PR, it mostly looks good, a few changes needed mentioned in the comments.
src/add/index.js
Outdated
@@ -16,21 +16,36 @@ module.exports = configure(({ ky }) => { | |||
if (options.chunker) searchParams.set('chunker', options.chunker) | |||
if (options.cidVersion) searchParams.set('cid-version', options.cidVersion) | |||
if (options.cidBase) searchParams.set('cid-base', options.cidBase) | |||
if (options.enableShardingExperiment != null) searchParams.set('enable-sharding-experiment', options.enableShardingExperiment) | |||
if (options.enableShardingExperiment != null) { |
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.
Were these changes necessary? I personally like curly brackets around if statement bodies, even one liners, but this has made everything inconsistent and is outside the scope of the intended change.
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.
No, they weren't necessary. They happened due to the default code styling settings I have globally in VS Code. If this style is important and gates PR merging, though, we should modify the linter settings to throw a warning or an error with this style. Ideally, we would get aegir lint --fix
to automatically resolve such warnings/errors too, which may happen out of the box when we enable the warning. I'll open an issue for this.
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.
Just opened the issue #1225
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.
I've disabled the Prettier
and JavaScript Standard Style
extensions for this workspace locally in VS Code so that automatic linting changes won't make it into a PR against this repo next time, but I still think the linting settings change is worth making to make it simpler for others to make PRs in the future.
@achingbrain Thanks for the quick review! I'll work on addressing the comments now. |
// An env where res.body getter for ReadableStream with getReader | ||
// is not supported, for example in React Native | ||
if (!body) { | ||
if (res.arrayBuffer) { |
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.
@achingbrain @hugomrdias Do we want to console.log
anything in this case, like "falling back to a hackier approach since the fetch being used here doesn't implement the streams spec"?
src/add/index.js
Outdated
@@ -52,7 +52,7 @@ module.exports = configure(({ ky }) => { | |||
} | |||
}) | |||
|
|||
function toCoreInterface ({ name, hash, size, mode, mtime }) { | |||
function toCoreInterface({ name, hash, size, mode, mtime }) { |
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.
@achingbrain The aegir linter also could use a rule for this
@achingbrain Okay, I think I've addressed all of your comments! Thanks again for the quick review. Could you please give this another review when you have a moment? I reverted all of the style changes manually, although it retrospect it may have been faster to configure some local workspace settings to match the styling conventions of this project. Longer term I think this would be a nice improvement to make. |
Yikes, it looks like there are a lot of merge conflicts now that another PR was merged. I'll work on resolving them. |
Looks like it was this PR #1183 |
@achingbrain @hugomrdias I don't think getting the conflicts resolved gates an interim PR review, though, in case you have time. Thanks! |
@achingbrain I fixed the merge conflicts. We need to decide how we want to handle this issue - alanshaw/stream-to-it#3 (comment) - before merging this, now that one of the previously modified files, |
Some tests are failing with the new logic introduced in this PR, like this one:
Interestingly those tests weren't failing with the earlier version of these changes against version |
The test failure was because I did a find/replace relative to an earlier version |
It looks like the Travis failure is just it hitting a timeout, which I don't think is something that my PR would increase the probability of, perhaps something that's just stochastic? |
As for the |
@pcowgill apologies I didn't get to this sooner. Did you look into adding a global afterResponse hook when in react native? It might be less invasive to add a What do you think? |
@alanshaw To make sure I understand the suggestion, which file are you thinking that change would land in? Thanks! |
@alanshaw Curious for your thoughts on the |
|
Just checked out this PR because when I run jest on my setup (ionic / Typescript / React / node 12), and just test a simple
my jest tests are green again :) |
we will be doing some changes around http requests handling soon to fix these issues, stay tuned. |
@hugomrdias That's great! Can you share any additional details about this? Thanks! |
@alanshaw Sure, that suggestion works for me. @hugomrdias Are you already planning on implementing the changes Alan described in the child package of the |
Will there still be the equivalent of an |
There will be no hooks and would advise against making the PR that specific problem needs to be fixed outside http-client |
Closes https://github.com/ipfs/js-ipfs-http-client/issues/1215
@hugomrdias @alanshaw Let me know what you think! The tests are passing, I added a new test case, and I've run the lint script.