wix / Detox

Gray box end-to-end testing and automation framework for mobile apps
https://wix.github.io/Detox/
MIT License
11.25k stars 1.92k forks source link

[RN-0.71 - iOS] The app has not responded to the network requests below: (id = -1000) isReady: {} #3949

Open tarikfp opened 1 year ago

tarikfp commented 1 year ago

What happened?

When running debug test script after a successful build, the app launches, then it gets stuck infinitely. (Note: Android is working fine, its only for iOS)

After timeout, it throws the following error:

image

What was the expected behaviour?

It should not get stuck, and process the test cases.

Was it tested on latest Detox?

Did your test throw out a timeout?

Help us reproduce this issue!

Simple react-native app, issue is reproducible in main branch https://github.com/tarikpnr/react-native-testing

In what environment did this happen?

Detox version: 20.1.3 React Native version: 0.71.2 Has Fabric (React Native's new rendering system) enabled: yes Node version: v16.19.1 Device model: iPhone 12 iOS version: 16.2 Xcode version: 14.2 Test-runner (select one): jest

Detox logs

Detox logs ``` paste logs here! ```

Device logs

Device logs ``` paste logs here! ```

More data, please!

Demonstration video (4x), starting from running yarn run detox test --configuration ios.sim.debug script.

https://user-images.githubusercontent.com/61876765/220784475-33760b13-a43e-4bc0-89b0-3b2bbba72c5a.mp4

tarikfp commented 1 year ago

I will share the artifacts below, since I was not able to put logs due to the following restriction from github: There was an error posting your comment: Body is too long,

artifacts.zip

noomorph commented 1 year ago

Looks like there are some stuck/pending network requests in your app:

{"params":{"status":{"app_status":"busy","busy_resources":[{"name":"dispatch_queue","description":{"queue":"Main Queue (<OS_dispatch_queue_main: com.apple.main-thread>)","works_count":1}},{"name":"one_time_events","description":{"event":"Network Request","object":"URL: “https://fakestoreapi.com/img/61pHAEJ4NML._AC_UX679_.jpg”"}},{"name":"one_time_events","description":{"event":"Network Request","object":"URL: “https://fakestoreapi.com/img/71HblAHs5xL._AC_UY879_-2.jpg”"}},{"name":"one_time_events","description":{"event":"Network Request","object":"URL: “https://fakestoreapi.com/img/61mtL65D4cL._AC_SX679_.jpg”"}},{"name":"run_loop","description":{"name":"Main Run Loop"}},{"name":"one_time_events","description":{"event":"Network Request","object":"URL: “https://fakestoreapi.com/img/51eg55uWmdL._AC_UX679_.jpg”"}},{"name":"one_time_events","description":{"event":"React Native (bundle load)","object":null}}]},"messageId":1},"messageId":1,"type":"currentStatusResult"}

e.g. https://fakestoreapi.com/img/61pHAEJ4NML._AC_UX679_.jpg – they are never ending or something like that

d4vidi commented 1 year ago

Why aren't the debug-sync logs shown - I wonder? Would have made what the problem is very clear.

noomorph commented 1 year ago

@d4vidi , the OP wrote why:

I will share the artifacts below, since I was not able to put logs due to the following restriction from github: There was an error posting your comment: Body is too long,

d4vidi commented 1 year ago

I meant in the terminal. If they're in debug, would make sense to bump their log-level to info. WDYT?

d4vidi commented 1 year ago

I meant in the terminal. If they're in debug, would make sense to bump their log-level to info. WDYT?

Strikes me odd: https://github.com/wix/Detox/blob/6145653d0077d5e406a48e539c3a3ea2f7d968bb/detox/src/client/Client.js#L265

Might have been an error that's triggered the debug "fallback" log instead, or - @tarikpnr have you by any chance actively disabled syncrhonization debugging?

noomorph commented 1 year ago

@d4vidi The synchronization was enabled. The OP mostly likely did not notice .

image

tarikfp commented 1 year ago

@d4vidi @noomorph After your feedbacks regarding the issue, I've decided to take another shot:

import React from 'react';
import {Button, Text, View} from 'react-native';
import {COMMON_STYLES} from './theme/common-styles';

const Counter = () => {
  const [counter, setCounter] = React.useState(0);

  return (
    <View style={COMMON_STYLES.flexCenter}>
      <Button
        testID="increase-btn"
        onPress={() => setCounter(prev => prev + 1)}
        title="Increase"
      />
      <Button
        testID="decrease-btn"
        onPress={() => setCounter(prev => prev - 1)}
        title="Decrease"
      />
      <Text testID="count-text">Count: {counter}</Text>
    </View>
  );
};

export default function App() {
  return <Counter />;
}
describe('Example', () => {
  beforeAll(async () => {
    await device.launchApp({
      newInstance: true,
    });
  });

  beforeEach(async () => {
    await device.reloadReactNative();
  });

  test('complete app flow', async () => {
    await element(by.id('increase-btn')).tap();
  });
});

https://user-images.githubusercontent.com/61876765/220995428-0f973a55-6869-40b0-9ee5-97a73993952a.mp4

ios.sim.debug.2023-02-23 18-07-38Z.zip


Unfortunately, it throws the same error, from what I can see it gets busy with event "React Native (bundle load)":

  data: {
    "params": {
      "status": {
        "busy_resources": [
          {
            "name": "one_time_events",
            "description": {
              "event": "React Native (bundle load)",
              "object": null
            }
          },
          {
            "name": "run_loop",
            "description": {
              "name": "Main Run Loop"
            }
          },
          {
            "name": "dispatch_queue",
            "description": {
              "queue": "Main Queue (<OS_dispatch_queue_main: com.apple.main-thread>)",
              "works_count": 1
            }
          }
        ],
        "app_status": "busy"
      },
      "messageId": 1
    },
    "messageId": 1,
d4vidi commented 1 year ago

@tarikpnr thanks for taking the extra-mile, it will definitely prove helpful.

d4vidi commented 1 year ago

@tarikpnr I've put in a serious effort, trying to run thereact-native-testing project on iOS. I've managed to overcome some issues (ruby + pod installations). Eventually stopped at getting this from metro when bundling the app:

error: ReferenceError: SHA-1 for file /Users/<omitted>nvm/versions/node/v14.18.2/lib/node_modules/react-native/node_modules/metro-runtime/src/polyfills/require.js (/Users/<omitted>nvm/versions/node/v14.18.2/lib/node_modules/react-native/node_modules/metro-runtime/src/polyfills/require.js) is not computed.
         Potential causes:
           1) You have symlinks in your project - watchman does not follow symlinks.
           2) Check `blockList` in your metro.config.js and make sure it isn't excluding the file path.

Anyways would you be able to try running that project with RN .70 instead of .71? I think the problem might lie there.

d4vidi commented 1 year ago

Update: I've managed to get passed that. Bottom line is that while the images download sure is on the slow side, the test ultimately passes (i.e. your problem does not reproduce). I think you might like to try to increase the timeout (120000ms may not be enough), on account of the download's slowness.

tarikfp commented 1 year ago

@d4vidi Thanks for your efforts. I have actually updated the repo by creating the new branch, as I also mentioned here you probably tested it on main branch which has third party API call. It'd be perfect if you switch to the branch called as ios-e2e-debug and test it from there. (Not sure tho, might not necessarily needed since you already managed to run it in main. But just curious to see if it is running on that branch too, as I was not able to run the test in a simple counter app, and we would make sure to determine whether its related to download's slowness or not by doing this way.)

And, have you done any changes to the repo to make it run? If not, then I doubt it is maybe sort of environment issue ?

tarikfp commented 1 year ago

TL&DR

It will not work in new architecture (when you see fabric: true in metro console) (still need confirmation)


Attempts

I ended up resetting everything related to iOS using react-native-clean-project, and having this new Podfile.lock seems to fix the issue.

Considering react-native-clean-project using the typical pod install but not bundle install && RCT_NEW_ARCH_ENABLED=1 bundle exec pod install which means it will end up setting up an environment without fabric or in other words, new architecture is NOT enabled.

According to docs, determining whether the new architecture is in use or not is simply checking fabric:trueoption.

Double-checked through the metro console, notice below there is no fabric: true option. And it did run the tests properly when I tried.

image

In contrast, fabric option was enabled in the initial video that I shared. See below:

image

I assume it initializes project with fabric by default using ,npx react-native@latest init AwesomeProjectcommand. Then, in the very next pod install it does revert fabric. If you want to keep fabric in the project, The default pod-install script should be the following as the docs suggest:

"scripts": {
  "pod-install": "RCT_NEW_ARCH_ENABLED=1 bundle exec pod install"
}

@d4vidi Most probably it was the case for you as well, there is a high chance that you may have initialized the project without fabric, therefore you were not able to reproduce the error I faced, just guessing at the moment, that's the reason it still needs confirmation.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe the issue is still relevant, please test on the latest Detox and report back.

Thank you for your contributions!

For more information on bots in this repository, read this discussion.

sgabriel commented 1 year ago

I'm facing the same issue, that all tests won't start when using fabric. They time out with this error

The app has not responded to the network requests below:
  (id = -1000) isReady: {}

Unresponded network requests might result in timeout errors in Detox tests.
stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe the issue is still relevant, please test on the latest Detox and report back.

Thank you for your contributions!

For more information on bots in this repository, read this discussion.

Numan-Munir commented 1 year ago

I'm facing the same issue, that all tests won't start when using fabric. They time out with this error

The app has not responded to the network requests below:

(id = -1000) isReady: {}

Unresponded network requests might result in timeout errors in Detox tests.

Screenshot 2023-06-08 at 12 48 57 PM
stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe the issue is still relevant, please test on the latest Detox and report back.

Thank you for your contributions!

For more information on bots in this repository, read this discussion.

badsyntax commented 1 year ago

Not stale, facing the same issue.

sam060584 commented 1 year ago

I am also facing the same issue on native-ios app

Numan-Munir commented 1 year ago

I am also facing the same issue on native-ios app

My issue has been resolved. I was using the "import * as Progress from "react-native-progress";" library to implement a progress bar. However, I have now commented it out.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe the issue is still relevant, please test on the latest Detox and report back.

Thank you for your contributions!

For more information on bots in this repository, read this discussion.

nmongiya commented 1 year ago

is there any workaround for this ?

timmyjose commented 10 months ago

I'm seeing the exact same issue with a React Native prototype (Turbo Modules (C++), New Architecture). Triggering the tests via eas build:

[ON_BUILD_SUCCESS_HOOK] 17:04:29.459 detox[43533] i The app has not responded to the network requests below:
[ON_BUILD_SUCCESS_HOOK]   (id = -1000) isReady: {}

Can we have an official word on whether this the New Architecture is supported/not supported/it's some other issue?

asafkorem commented 10 months ago

I'm seeing the exact same issue with a React Native prototype (Turbo Modules (C++), New Architecture). Triggering the tests via eas build:

[ON_BUILD_SUCCESS_HOOK] 17:04:29.459 detox[43533] i The app has not responded to the network requests below:
[ON_BUILD_SUCCESS_HOOK]   (id = -1000) isReady: {}

Can we have an official word on whether this the New Architecture is supported/not supported/it's some other issue?

Hey @timmyjose, we do not support turbo modules ATM however we're aiming to support that soon. No official ETA unfortunately.

asafkorem commented 10 months ago

is there any workaround for this ?

Hey @nmongiya, can you please elaborate what issue are you facing (provide logs or any information that might be useful)? The error on the issue title is quite general and might indicate on a different issue than yours.

timmyjose commented 10 months ago

Hey @asafkorem, thank you for confirming that. 🙏 It's a bit unfortunate, but at least now we know that it's not an issue in our setup! We're now looking into using the Old Architecture (non Turbo Modules) in the meantime, and when support for Turbo Modules is available (hopefully soon!), we'll probably migrate back.

skylarbarrera commented 10 months ago

following here for turbo module support

walmat commented 10 months ago

Following for turbo

stale[bot] commented 8 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe the issue is still relevant, please test on the latest Detox and report back.

Thank you for your contributions!

For more information on bots in this repository, read this discussion.

walmat commented 8 months ago

Still happening on latest. Remarking this as not stale.

BrodyHughes commented 7 months ago

still seems to be an issue. following for turbo module support.

Sky commented 1 month ago

Looks like same issue as here: https://github.com/wix/Detox/issues/4506 Up for New Architecture support