-
Notifications
You must be signed in to change notification settings - Fork 127
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
fix: use response._bodyInit
as fallback for react-native and qq
#398
Conversation
_bodyInit
support
Codecov ReportAll modified and coverable lines are covered by tests β
Additional details and impacted files@@ Coverage Diff @@
## main #398 +/- ##
===========================================
+ Coverage 56.86% 70.14% +13.28%
===========================================
Files 16 17 +1
Lines 728 536 -192
Branches 113 138 +25
===========================================
- Hits 414 376 -38
+ Misses 303 149 -154
Partials 11 11 β View full report in Codecov by Sentry. |
_bodyInit
supportresponse._bodyInit
as fallback for react-native and qq
@pi0 so I just checked with React Native running on my android phone When interface Blob {
readonly size: number;
readonly type: string;
slice(start?: number, end?: number, contentType?: string): Blob;
} So none of the standard methods are present. As far as I can tell there's no way to get the actual data out of it. |
Additionally logging the _bodyInit to the console outputs the following: {"_data": {"__collector": {}, "blobId": "244dfb46-0c73-45f8-99be-cfd8b2bb971f", "offset": 0, "size": 1256}} When normally logging a Blob would look like this: Blob { size: 11, type: '' } |
I see, basically seems stream mode is broken. Although now other types (text/json) work right? |
Yes I both text and json work as expected |
π Linked issue
Fixes #324
β Type of change
π Description
This pr is essentially a one line change to add react native support. It checks
response._bodyInit
in addition toresponse.body
to see if a body exists in the response.Normally I would say that this is an upstream issue that react native should fix, but the reality is fetch has not been spec compliant in react native for a long time, and it doesn't seem like there has been any meaningful progress in that department either. So I don't think it's practical to wait on them.
I would also argue that even though this is a runtime specific check it shouldn't add any overhead for maintainers because its such a small change. I've also included comments explaining what the additional
_bodyInit
check is for and under what conditions it can be removed.Additionally this repo does have a precedent for runtime specific check. In
./src/fetch.ts
line 84, there is a check for a chromium specific API. So this change would be in line with that.ofetch/src/fetch.ts
Line 84 in f7f9463
In all I think this is a worthwhile change as it would let users use the same fetch library across, node, browsers, and react native.
π Checklist