React-native: Simulator waits for processing a request using fetch until a click is made on the screen

Created on 8 Sep 2015  路  13Comments  路  Source: facebook/react-native

Hi all,

In one of my action callers of my app, where I need to call an external API (using fetch api), I have something like this.

console.log('fetching...');

_pendingRequests[key] = fetch(url, metadata).then(r => r.json())
                                .then(data => { dispatch(key, data, params) })
                                .catch(apiError);

With all the other fetches everything works fine, but there is a fetch that happens when some coordinates are updated, the callback is called, and thus this action caller is called,

fetching...

is displayed in the console but until I don't CLICK on the simulator the promise is not resolved and so the response is not dispatched, in the device everything works as expected.

What can it be?

Thanks

Locked

Most helpful comment

Same problem.
RN 0.46.1

All 13 comments

Are you using the Chrome debugger? I could see that causing issues... Basically your click is causing React Native's event loop to run and I think another event loop (V8 maybe) is running without RN being aware of it.

humm.. yes, in fact when I disable Chrome debugger now it doesn't work at all (ie. the request arrives to the backend but the promise is not resolved, clicking on the screen or not)

I think we need more information about the context of this fetch call -- given that all others work fine, there is nothing specific about this that I see causing problems. Please try to post a reproducible example that we can run against! Otherwise there's not much more we can say here :smile:

Closing, ping me when you have a chance to reply and I can reopen!

I'm seeing this same behavior. It only happens when using the chrome debugger. I'm digging in and will report back when I know more.

Oh, I upgraded to 0.24.x to 0.26.x and the problem was resolved.

I also have this problem and it happen on 0.26.x , when i use code from https://facebook.github.io/react-native/docs/sample-application-movies.html

when i disable Chrome debug "remote debug" model , the bug is gone.
so it seem like something wrong wiht remote debug

Hi, I'm having exactly the same issue in 0.33 after upgrade from 0.32. After disconnecting from the debugger it works fine

Same problem as @martin-cech says... 馃槙

Turns out it might not be relevant to version of React, I reverted to 0.32 and the problem was still there. I tried deleting node_modules folder, even completely clean git checkout but nothing worked. I think after

rm -rf /usr/local/lib/node_modules/npm/node_modules

the issue went away. No guarantees whether that works or why, I was just trying to clean as much as possible.

I'm seeing the same problem now, with RN 0.45.1 and React 16.0.0-alpha.12.

I'm having the same issue. When I'm debugging with Chrome, for each request, I have to click on the app (simulator) to be able to make each request. Without debugging I works fine :(

Same problem.
RN 0.46.1

Was this page helpful?
0 / 5 - 0 ratings