Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native Android: Fetch Requests only working when React Native Debugger is connected

I have a weird issue with making fetch requests to my API on Android (using React Apollo). In the dev build as well as the release build fetch does not work. As soon as I power up React Native Debugger and enable Enable Network Inspect the requests work.

I have no idea how to debug the requests as they are not shown in the debugger without Network Inspect enabled.

Any idea how I could find the error or did anyone of you run into the same issue?

like image 279
mxmtsk Avatar asked Sep 02 '25 05:09

mxmtsk


1 Answers

This is presumably because, when this question was asked, React Native did not support fetch, if I'm not mistaken - and when debugging at that time you had to beware of some oddities, such as the debugger having access to objects/methods which were not available in the actual React Native runtime.

When the debugger was connected, the code is executed in the debugger rather than on the actual device, creating this effect.

You can see here that fetch requires a polyfill in versions from 2018.

We had to deal with other frustrations in this vein, like the authentication for our app needing to be re-authenticated when first connecting the debugger.

like image 170
Slbox Avatar answered Sep 04 '25 19:09

Slbox