Skip to content
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

[React Native] V8.14.0 breaks normal fetch behavior #3027

Closed
e-verhoeven opened this issue Sep 27, 2023 · 4 comments · Fixed by #3030
Closed

[React Native] V8.14.0 breaks normal fetch behavior #3027

e-verhoeven opened this issue Sep 27, 2023 · 4 comments · Fixed by #3030
Labels
bug Something isn't working react-native to do with react-native

Comments

@e-verhoeven
Copy link

e-verhoeven commented Sep 27, 2023

The following commit seems to have broken the normal fetch() behavior in React Native:

It seems like the Polyfill(s) overwrites global behavior that results in broken fetch responses using RN's default fetch() API. After importing the library and calling my own https endpoints using fetch, the await response.json() throws an Unexpected identifier "object" error and the arrayBuffer of my response seems to be empty.

It's been a hell of a ride tracing this back to react-three-fiber 8.14.0 :) Downgrading to 8.13.9 seems to resolve the issue.

@e-verhoeven e-verhoeven changed the title [React Native] V8.14.x onwards breaks normal fetch behavior [React Native] V8.14.0 breaks normal fetch behavior Sep 27, 2023
@CodyJasonBennett CodyJasonBennett added bug Something isn't working react-native to do with react-native labels Sep 27, 2023
@CodyJasonBennett
Copy link
Member

Are you using fetch as part of a loader or generally? I'm inclined to revert those changes and forgo react-native's networking stack for other reasons, but what makes this more concerning than just R3F is this has been upstreamed in facebook/react-native#39276. Can you share a simple test case? I'll need to get this straightened on both ends.

@e-verhoeven
Copy link
Author

e-verhoeven commented Sep 28, 2023

Hi Cody,

What I'm doing is just rendering a component with a three-fiber canvas within a parent component that also calls several of our own backend API's (just normal HTTPS endpoints with JSON responses). Exactly the same calls that would normally successfully execute (i.e. unpack the response using await reponse.json() or await response.arrayBuffer()) in any other place in the app, will fail as soon as I import stuff from the react-three-fiber/native 8.14.0 in that child component.

We're on:
"react": "18.2.0",
"react-native": "0.72.4",
"expo-gl": "^13.2.0",
"expo": "^49.0.10"

@CodyJasonBennett
Copy link
Member

I'm not able to reproduce locally, testing with data:application/json;base64,eyJ0ZXN0Ijp0cnVlfQ== as JSON, but I published v8.14.4 which unsets the Blob global. See if that helps and if you have a withstanding test case I can take a closer look.

@CodyJasonBennett
Copy link
Member

I've since merged #3030 and #3042 in 8.14.6, the latter reverting changes from 8.14 directly. Let me know if the first was helpful for future reference, but it resolves this issue surely as of now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working react-native to do with react-native
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants