Skip to content

File fetching broken since commit 0c1d2b9 #1371

@ldaudet

Description

@ldaudet

Hi there!

Thanks a lot for the work on this library! I am using it in a react native app to run code like this: https://snack.expo.dev/@bacon/documentpicker-to-blob (line 24), to grab an image file that I will then upload to the backend.

This worked for the longest time, but after uploading to the latest version of expo, it also uploaded the version of react native, which in turned updated our version of fetch. The problem is that with the latest version of fetch, the fetch of file doesn't work anymore, as described here: facebook/react-native#38625 (comment)

After looking at the code, I realized that the issue was actually do to the work on commit 0c1d2b9 where you added a check for the return code to be between certain values:

  if (this.status < 200 || this.status > 599) {
    throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].")
  }

When removing this check, everything works just fine with fetching the file, even with the lastest version of fetch, as the fetch of the a file return a status 0.

Would it be possible to either remove the check, or update the code to get a 200 status on successfully fetching a file?

Thanks a lot

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions