🐛 Detox: Network is busy

Describe the bug

When testing my app using my Xampp apache server, I have a problem with Detox. It is stuck and reports Detox: Network is busy. If I disable network requests from my app, Detox works normally., but since the network requests are disabled, I can’t really test the app. If the network requests are fetched with anything than 10.0. 2.2 and 192.168. x.x (that is my IPv4), it works.

To Reproduce

  • I have tested this issue on the latest Detox release and it still reproduces

Steps to reproduce:

  1. Clone Detox latest example
  2. Modify your app.js as follows
import React from 'react';
import {
  AppRegistry,
  Text,
  View
} from 'react-native';

const Example = () => {
  useEffect(() => {
    for (const i = 0; i < 100; i++) {
      setTimeout(doRequest, 1000);
    }
  });

  const doRequest = () => {
    // replace url with your local server, mine is: http://192.168.x.x:8080
    const url = "";
    fetch(url)
      .then(() => console.log("Success"))
      .catch(() => console.log("Error"));
  }

  return (
    <View style={{ flex: 1, paddingTop: 20, justifyContent: 'center', alignItems: 'center' }}>
      <Text style={{ fontSize: 25 }}>
        Network requests in the background
    </Text>
    </View>
  )
}

AppRegistry.registerComponent('example', () => Example);
  1. If the above example doesn’t make Detox freeze, try to connect to any localhost socket-io instance, since it does many requests in the backend.

Expected behavior

  • I expected Detox to not have a conflict with 10.0. 2.2 and 192.168. x.x (that is my IPv4). That is: making a request with these IPs doesn’t make Detox freeze reporting “Network is busy”.

  • I expected Detox to work seamlessly with a local socket-io connection.

  • Also, to start testing instead of timing out.

Device and Verbose Detox Logs

After running
adb logcat *:S Detox:V -T 50

I get

--------- beginning of system
--------- beginning of main
09-12 15:51:11.844 20385 20385 I Detox   : Network is busy
09-12 15:51:11.861 20385 20385 I Detox   : Network is busy
09-12 15:51:12.827 20385 20385 I Detox   : Network is busy
09-12 15:51:12.850 20385 20385 I Detox   : Network is busy
09-12 15:51:12.957 20385 20385 I Detox   : Network is busy
09-12 15:51:12.975 20385 20385 I Detox   : Network is busy
09-12 15:51:13.830 20385 20385 I Detox   : Network is busy
09-12 15:51:13.850 20385 20385 I Detox   : Network is busy
09-12 15:51:14.256 20385 20385 I Detox   : Network is busy
09-12 15:51:14.275 20385 20385 I Detox   : Network is busy
09-12 15:51:14.832 20385 20385 I Detox   : Network is busy
09-12 15:51:14.850 20385 20385 I Detox   : Network is busy
09-12 15:51:14.980 20385 20385 I Detox   : Network is busy
09-12 15:51:14.998 20385 20385 I Detox   : Network is busy
09-12 15:51:15.834 20385 20385 I Detox   : Network is busy
09-12 15:51:15.851 20385 20385 I Detox   : Network is busy
09-12 15:51:16.836 20385 20385 I Detox   : Network is busy
09-12 15:51:16.854 20385 20385 I Detox   : Network is busy
09-12 15:51:16.984 20385 20385 I Detox   : Network is busy
09-12 15:51:17.001 20385 20385 I Detox   : Network is busy
09-12 15:51:17.837 20385 20385 I Detox   : Network is busy
09-12 15:51:17.857 20385 20385 I Detox   : Network is busy
09-12 15:51:18.765 20385 20385 I Detox   : Network is busy
09-12 15:51:18.785 20385 20385 I Detox   : Network is busy
09-12 15:51:18.841 20385 20385 I Detox   : Network is busy
09-12 15:51:18.857 20385 20385 I Detox   : Network is busy
09-12 15:51:18.989 20385 20385 I Detox   : Network is busy
09-12 15:51:19.007 20385 20385 I Detox   : Network is busy
09-12 15:51:19.842 20385 20385 I Detox   : Network is busy
09-12 15:51:19.860 20385 20385 I Detox   : Network is busy
09-12 15:51:20.845 20385 20385 I Detox   : Network is busy
09-12 15:51:20.863 20385 20385 I Detox   : Network is busy
09-12 15:51:20.993 20385 20385 I Detox   : Network is busy
09-12 15:51:21.011 20385 20385 I Detox   : Network is busy
09-12 15:51:21.847 20385 20385 I Detox   : Network is busy
09-12 15:51:21.865 20385 20385 I Detox   : Network is busy
09-12 15:51:22.849 20385 20385 I Detox   : Network is busy
09-12 15:51:22.867 20385 20385 I Detox   : Network is busy
09-12 15:51:23.016 20385 20385 I Detox   : Network is busy
09-12 15:51:23.033 20385 20385 I Detox   : Network is busy
09-12 15:51:23.276 20385 20385 I Detox   : Network is busy
09-12 15:51:23.294 20385 20385 I Detox   : Network is busy
09-12 15:51:23.852 20385 20385 I Detox   : Network is busy
09-12 15:51:23.868 20385 20385 I Detox   : Network is busy
09-12 15:51:24.835 20385 20385 I Detox   : Network is busy
09-12 15:51:24.853 20385 20385 I Detox   : Network is busy
09-12 15:51:24.853 20385 20385 I Detox   : Network is busy
09-12 15:51:25.020 20385 20385 I Detox   : Network is busy
09-12 15:51:25.039 20385 20385 I Detox   : Network is busy
09-12 15:51:25.837 20385 20385 I Detox   : Network is busy
09-12 15:51:25.856 20385 20385 I Detox   : Network is busy
09-12 15:51:26.840 20385 20385 I Detox   : Network is busy
09-12 15:51:26.857 20385 20385 I Detox   : Network is busy
09-12 15:51:27.024 20385 20385 I Detox   : Network is busy
09-12 15:51:27.042 20385 20385 I Detox   : Network is busy
09-12 15:51:27.786 20385 20385 I Detox   : Network is busy
09-12 15:51:27.802 20385 20385 I Detox   : Network is busy
09-12 15:51:27.841 20385 20385 I Detox   : Network is busy
09-12 15:51:27.860 20385 20385 I Detox   : Network is busy
09-12 15:51:28.844 20385 20385 I Detox   : Network is busy
09-12 15:51:28.863 20385 20385 I Detox   : Network is busy
09-12 15:51:29.029 20385 20385 I Detox   : Network is busy
09-12 15:51:29.047 20385 20385 I Detox   : Network is busy
09-12 15:51:29.845 20385 20385 I Detox   : Network is busy
09-12 15:51:29.863 20385 20385 I Detox   : Network is busy
09-12 15:51:30.034 20385 20385 I Detox   : Network is busy
09-12 15:51:30.052 20385 20385 I Detox   : Network is busy
09-12 15:51:30.847 20385 20385 I Detox   : Network is busy
09-12 15:51:30.865 20385 20385 I Detox   : Network is busy
09-12 15:51:30.884 20385 20385 I Detox   : Network is busy
09-12 15:51:30.905 20385 20385 I Detox   : Network is busy
09-12 15:51:31.051 20385 20385 I Detox   : Network is busy
09-12 15:51:31.051 20385 20385 I Detox   : Network is busy
09-12 15:51:31.849 20385 20385 I Detox   : Network is busy
09-12 15:51:31.867 20385 20385 I Detox   : Network is busy
09-12 15:51:32.295 20385 20385 I Detox   : Network is busy
09-12 15:51:32.312 20385 20385 I Detox   : Network is busy
09-12 15:51:32.838 20385 20385 I Detox   : Network is busy
09-12 15:51:32.873 20385 20385 I Detox   : Network is busy
09-12 15:51:33.058 20385 20385 I Detox   : Network is busy
09-12 15:51:33.075 20385 20385 I Detox   : Network is busy
09-12 15:51:33.855 20385 20385 I Detox   : Network is busy
09-12 15:51:33.872 20385 20385 I Detox   : Network is busy
09-12 15:51:34.120 20385 20385 I Detox   : Network is busy
09-12 15:51:34.120 20385 20385 I Detox   : Network is busy
09-12 15:51:34.211 20385 20385 I Detox   : Network is busy
09-12 15:51:34.239 20385 20385 I Detox   : Network is busy
09-12 15:51:34.241 20385 20385 I Detox   : Network is busy

Environment (please complete the following information):

  • Detox: 17.4.10
  • React Native: 0.63.2
  • Node: 12.10.0
  • Device: Nexus_5X_API_29_x86
  • OS: Windows 10, 64 bits, 16 GB RAM. Intel i7
  • Test-runner (select one): jest-circus

Temporal potential fix
I disable Socket.io and it seems to reduce the amount of requests, hence blocking Detox less.
Here is the log after

Each time you see Detox : Network is busy in this log it is a request which blocked Detox

09-12 16:05:35.812 21703 21703 I Detox   : Network is busy
09-12 16:05:36.307 21703 21703 I Detox   : Network is busy
09-12 16:05:37.984 21703 21703 I Detox   : Network is busy
09-12 16:05:38.323 21703 21703 I Detox   : Network is busy
09-12 16:05:38.342 21703 21703 I Detox   : Network is busy
09-12 16:05:38.649 21703 21703 I Detox   : Network is busy
09-12 16:05:38.668 21703 21703 I Detox   : Network is busy
09-12 16:05:39.314 21703 21703 I Detox   : UIManagerModule is busy.
09-12 16:05:39.328 21703 21703 I Detox   : UIManagerModule is busy.
09-12 16:05:39.347 21703 21703 I Detox   : UIManagerModule is busy.
09-12 16:05:39.770 21703 21703 I Detox   : UIManagerModule is busy.
09-12 16:05:41.329 21703 21703 I Detox   : Network is busy
09-12 16:05:41.337 21703 21703 I Detox   : Network is busy
09-12 16:05:41.356 21703 21703 I Detox   : Network is busy
09-12 16:05:41.575 21703 21703 I Detox   : Network is busy
09-12 16:05:43.228 21703 21703 I Detox   : UIManagerModule is busy.
09-12 16:05:43.236 21703 21703 I Detox   : AnimatedModule is busy.
09-12 16:05:43.339 21703 21703 I Detox   : AnimatedModule is busy.
09-12 16:05:43.354 21703 21703 I Detox   : AnimatedModule is busy.
09-12 16:05:44.022 21703 21703 I Detox   : AnimatedModule is busy.
09-12 16:05:44.040 21703 21703 I Detox   : AnimatedModule is busy.
09-12 16:05:44.181 21703 21703 I Detox   : AnimatedModule is busy.
09-12 16:05:44.208 21703 21703 I Detox   : UIManagerModule is busy.
09-12 16:05:44.225 21703 21703 I Detox   : AnimatedModule is busy.
09-12 16:05:44.346 21703 21703 I Detox   : AnimatedModule is busy.
09-12 16:05:44.365 21703 21703 I Detox   : AnimatedModule is busy.
09-12 16:05:44.768 21703 21703 I Detox   : AnimatedModule is busy.
09-12 16:05:44.785 21703 21703 I Detox   : AnimatedModule is busy.
09-12 16:05:45.053 21703 21703 I Detox   : AnimatedModule is busy.
09-12 16:05:45.070 21703 21703 I Detox   : AnimatedModule is busy.
09-12 16:05:45.203 21703 21703 I Detox   : AnimatedModule is busy.
09-12 16:05:45.229 21703 21703 I Detox   : UIManagerModule is busy.
09-12 16:05:45.249 21703 21703 I Detox   : AnimatedModule is busy.
09-12 16:05:45.330 21703 21703 I Detox   : AnimatedModule is busy.
09-12 16:05:45.350 21703 21703 I Detox   : AnimatedModule is busy.
09-12 16:05:46.231 21703 21703 I Detox   : AnimatedModule is busy.
09-12 16:05:46.255 21703 21703 I Detox   : UIManagerModule is busy.
09-12 16:05:46.267 21703 21703 I Detox   : AnimatedModule is busy.
09-12 16:05:46.337 21703 21703 I Detox   : AnimatedModule is busy.
09-12 16:05:46.354 21703 21703 I Detox   : AnimatedModule is busy.
09-12 16:05:46.770 21703 21703 I Detox   : AnimatedModule is busy.
09-12 16:05:46.790 21703 21703 I Detox   : AnimatedModule is busy.
09-12 16:05:47.237 21703 21703 I Detox   : AnimatedModule is busy.

2 thoughts on “🐛 Detox: Network is busy

  1. Hi @noomorph,

    I just updated the example to reproduce the issue.
    The following works perfectly

    import React, { useEffect } from 'react';
    import { AppRegistry, Text, View } from 'react-native';
    
    const Example = () => {
        let sentRequests = 0;
        useEffect(() => {
            let interval = setInterval(() => {
                sendRequest();
    
                if (sentRequests == 100) {
                    clearInterval(interval);
                    sentRequests = 0;
                }
    
                console.log('Sending request no: ', sentRequests);
                sentRequests++;
            }, 100);
        }, []);
    
        const sendRequest = () => {
            const url = 'http://google.com';
            fetch(url)
                .then(() => console.log('Success'))
                .catch(() => console.log('Error'));
        };
    
        return (
            <View style={{ flex: 1, paddingTop: 20, justifyContent: 'center', alignItems: 'center' }}>
                <Text style={{ fontSize: 25 }}>{'Network requests in the background'}</Text>
            </View>
        );
    };
    
    AppRegistry.registerComponent('example', () => Example);

    But if instead of sending the requests to http://google.com, I send them to my local IP http://192.168.x.x:8080. Detox freezes. It waits till all the requests are completed before it proceeds.

    I suspect a conflict between Detox and localhost requests.

    Thanks

    Franz