Detox: [DetoxServer.js/CANNOT_FORWARD] role=testee not connected

Created on 28 Oct 2019  Â·  19Comments  Â·  Source: wix/Detox

Describe the bug
I have Detox tests successfully being built and running on an iOS Simulator. I have Detox successfully building for Android, but when attempting to run the tests, I see the app launch and then error because the DetoxServer is unable to forward. The test shows it is unassigned.

To Reproduce

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

Running the following command:
yarn run detox test -c android.emu.release --loglevel trace

Environment (please complete the following information):

  • Detox: ^14.5.1
  • React Native: 0.60.5
  • Node: ^8.3 || >=10.*
  • Device: emulator-15018 device
  • OS: API 28

Device and Verbose Detox Logs

detox[70981] DEBUG: [exec.js/EXEC_CMD, #17] /Users/mvd/Library/Android/sdk/platform-tools/adb -s emulator-15018 shell "ps | grep \"com\.app_name\.app$\""
detox[70981] TRACE: [exec.js/EXEC_SUCCESS, #17] u0_a106      29575  1934 1452728 123920 0                   0 S com.app_name.app

detox[29575] TRACE: [ArtifactsManager.js/LIFECYCLE] artifactsManager.onLaunchApp({ deviceId: 'emulator-15018',
  bundleId: 'com.app_name.app',
  launchArgs:
   { detoxServer: 'ws://localhost:50780',
     detoxSessionId: 'beebae37-5672-7400-eb92-e9f14ad9b594' },
  pid: 29575 })
detox[70981] TRACE: [AsyncWebSocket.js/WEBSOCKET_SEND] {"type":"isReady","params":{},"messageId":-1000}
detox[70981] TRACE: [DetoxServer.js/MESSAGE] role=tester action=isReady (sessionId=beebae37-5672-7400-eb92-e9f14ad9b594)
detox[70981] DEBUG: [DetoxServer.js/CANNOT_FORWARD] role=testee not connected, cannot fw action (sessionId=beebae37-5672-7400-eb92-e9f14ad9b594)
A test to validate the Login page assigned to undefined
triagbug android

All 19 comments

Does anyone have any ideas or recommendations for this issue?

@fancychimp
I tried a lot of things, but I think what fixed it for me was setting android/build.gradle with this:

buildscript {
    ext {
        targetSdkVersion = 27
    }
}

and then using an emulator on sdk/api 27.

@kbowman-yaro thank you! This seems like the solution for now.

Thanks for this solution. Unfortunately, we're using APIs that require TargetSdkVersion = 28 so this doesn't work for me, as setting TargetSdkVersion to 27 produces code that fails in the detox build stage.

Yeah, I still had to mess around with the build 👎and now have to use a targetSdkVersion that's two versions behind. Hopefully this will be addressed soon.

I'm experiencing the same issue in debug mode. targetSdkVersion = 27 does not work for me. App launches but never kicks off the tests. I have a whole suite running for iOS without any issues.

```detox[33244] TRACE: [AsyncWebSocket.js/WEBSOCKET_SEND] {"type":"isReady","params":{},"messageId":-1000}
detox[33244] TRACE: [DetoxServer.js/MESSAGE] role=tester action=isReady (sessionId=8dbde982-d961-7cb0-4ee8-fcb5ee9c3b46)
detox[33244] DEBUG: [DetoxServer.js/CANNOT_FORWARD] role=testee not connected, cannot fw action (sessionId=8dbde982-d961-7cb0-4ee8-fcb5ee9c3b46)
detox[33244] TRACE: [exec.js/SPAWN_STDOUT, #16] INSTRUMENTATION_STATUS: class=za.co.yoco.DetoxTest
INSTRUMENTATION_STATUS: current=1
INSTRUMENTATION_STATUS: id=AndroidJUnitRunner

detox[33244] TRACE: [exec.js/SPAWN_STDOUT, #16] INSTRUMENTATION_STATUS: numtests=1
INSTRUMENTATION_STATUS: stack=java.lang.RuntimeException: Could not launch intent Intent { act=android.intent.action.MAIN flg=0x14000000 cmp=za.co.yoco/.MainActivity (has extras) } within 45 seconds. Perhaps the main thread has not gone idle within a reasonable amount of time? There could be an animation or something constantly repainting the screen. Or the activity is doing network calls on creation? See the threaddump logs. For your reference the last time the event queue was idle before your activity launch request was 1574780302720 and now the last time the queue went idle was: 1574780302720. If these numbers are the same your activity might be hogging the event queue.
at androidx.test.runner.MonitoringInstrumentation.startActivitySync(MonitoringInstrumentation.java:481)
at androidx.test.rule.ActivityTestRule.launchActivity(ActivityTestRule.java:358)
at com.wix.detox.Detox.runTests(Detox.java:117)
at com.wix.detox.Detox.runTests(Detox.java:93)
at za.co.yoco.DetoxTest.runDetoxTests(DetoxTest.java:22)
at java.lang.reflect.Method.invoke(Native Method)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at androidx.test.rule.ActivityTestRule$ActivityStatement.evaluate(ActivityTestRule.java:531)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at androidx.test.ext.junit.runners.AndroidJUnit4.run(AndroidJUnit4.java:104)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at androidx.test.internal.runner.TestExecutor.execute(TestExecutor.java:56)
at androidx.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:392)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2075)```

any ideas what's going on here?

@Imtiyaazg Same for me.

My targetSdkVersion is 28, on an emulator running version 28 it didn't run, an emulator running version 27 worked fine.

My targetSdkVersion is 28, on an emulator running version 28 it didn't run, an emulator running version 27 worked fine.

are you running it in debug mode? Also which version of react are you using?

I can get the example app running fine, but my project won't. I've tried all combination oof targetSdkVersions and emulators

Yup, running debug mode. React version 16.6.3. React native 0.59.10. I'm using the latest android studio and updated avd, also created new emulators.

I also want to add I start experiencing similar behaviours when using mocks, on both ios and and android. Maybe that is the cause.

ok, this is blocking us completely from proceeding with our Android automation project. I hope this issue gets sorted out soon.

We started seeing the problem, when we updated to RN 0.61.4. So it doesn't
have anything to do with mocks (as we currently don't have any).

On Thu, Nov 28, 2019 at 5:00 AM Imtiyaazg notifications@github.com wrote:

ok, this is blocking us completely from proceeding with our Android
automation project. I hope this issue gets sorted out soon.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/wix/Detox/issues/1716?email_source=notifications&email_token=AAGVYRS5RKU7PERZYD46UFLQV66HZA5CNFSM4JF3MLB2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEFMRGQQ#issuecomment-559485762,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAGVYRUXC5QIGGWOCEKPJS3QV66HZANCNFSM4JF3MLBQ
.

On my end I can confirm that this has everything to do with Animations keeping the threads busy. I went over each place I had an animation, mocked it and killed the animation and the tests started to run. I'm going to go back now, and restore them one by one to see who is killing the threads.

@fancychimp I really want to help but the description is pretty vague. Is it feasible to provide an example project that would reproduce this? Could you also provide the emulator logs from around when this takes place?

Confirm what @iamjon is saying - I have an infinite animation on the background of the app and Detox was waiting for the animation to end. All tests were failing because of the timeout.
Removed the animation - everything is working tests are passing!

I have similar issue with iOS test. RN is 0.61.2 and detox 14.9.1. I stetted up detox, start app and run tests and every time detox was unable to assign test to device.

```$ detox test ./__tests__/e2e --configuration ios.sim.debug --reuse --loglevel verbose
detox[72358] INFO: [test.js] configuration="ios.sim.debug" loglevel="verbose" reuse=true reportSpecs=true DETOX_START_TIMESTAMP=1577103679924 node_modules/.bin/jest --config ./test/jest.detox.js '--testNamePattern=^((?!:android:).)*$' --maxWorkers 1 ./__tests__/e2e
detox[72359] INFO: [DetoxServer.js] server listening on localhost:54515...
detox[72359] DEBUG: [AsyncWebSocket.js/WEBSOCKET_OPEN] opened web socket to: ws://localhost:54515
detox[72359] DEBUG: [DetoxServer.js/LOGIN] role=tester, sessionId=dec60296-63e5-652a-0ca1-880bb4279670
detox[72359] DEBUG: [DetoxServer.js/LOGIN_SUCCESS] role=tester, sessionId=dec60296-63e5-652a-0ca1-880bb4279670
detox[72359] DEBUG: [exec.js/EXEC_CMD, #0] applesimutils --list --byType "iPhone Xs"
detox[72359] DEBUG: [exec.js/EXEC_CMD, #1] applesimutils --list --byId E74429B1-BDDC-4578-AABA-BC3CAE9B91C6 --maxResults 1
detox[72359] DEBUG: [exec.js/EXEC_CMD, #2] /usr/bin/xcrun simctl terminate E74429B1-BDDC-4578-AABA-BC3CAE9B91C6 com.rocketbank.app
detox[72359] DEBUG: [exec.js/EXEC_TRY, #2] Terminating com.rocketbank.app...
detox[72359] DEBUG: [exec.js/EXEC_SUCCESS, #2] com.rocketbank.app terminated
detox[72359] DEBUG: [exec.js/EXEC_CMD, #3] SIMCTL_CHILD_DYLD_INSERT_LIBRARIES="/Users/grigory.lapshin/Library/Detox/ios/47f77a0ffb0b171831375da3e8f2fcfb74e08644/Detox.framework/Detox" /usr/bin/xcrun simctl launch E74429B1-BDDC-4578-AABA-BC3CAE9B91C6 com.rocketbank.app --args -detoxServer "ws://localhost:54515" -detoxSessionId "dec60296-63e5-652a-0ca1-880bb4279670"
detox[72359] DEBUG: [exec.js/EXEC_TRY, #3] Launching com.rocketbank.app...
detox[72359] DEBUG: [exec.js/EXEC_CMD, #4] /usr/bin/xcrun simctl get_app_container E74429B1-BDDC-4578-AABA-BC3CAE9B91C6 com.rocketbank.app
detox[72359] INFO: [AppleSimUtils.js] com.rocketbank.app launched. To watch simulator logs, run:
/usr/bin/xcrun simctl spawn E74429B1-BDDC-4578-AABA-BC3CAE9B91C6 log stream --level debug --style compact --predicate 'processImagePath beginsWith "/Users/grigory.lapshin/Library/Developer/CoreSimulator/Devices/E74429B1-BDDC-4578-AABA-BC3CAE9B91C6/data/Containers/Bundle/Application/B14977A5-6B50-4584-BD81-4F467504164B/Serenity.app"'
detox[72359] DEBUG: [DetoxServer.js/CANNOT_FORWARD] role=testee not connected, cannot fw action (sessionId=dec60296-63e5-652a-0ca1-880bb4279670)
detox[72359] DEBUG: [DetoxServer.js/LOGIN] role=testee, sessionId=dec60296-63e5-652a-0ca1-880bb4279670
detox[72359] DEBUG: [DetoxServer.js/LOGIN_SUCCESS] role=testee, sessionId=dec60296-63e5-652a-0ca1-880bb4279670
Login: should have welcome screen
Login: should have welcome screen [FAIL]
Login: enter
detox[72359] INFO: Login assigned to undefined
Login: enter [FAIL]


But surprisingly if I manually enter my app in debug mode and connect JS debugger the test runs!

...
detox[71593] INFO: Login assigned to E74429B1-BDDC-4578-AABA-BC3CAE9B91C6 (iPhone Xs)
...
```

Maybe it could help to triage bug.

The solution mentioned here: https://github.com/wix/Detox/issues/1743#issuecomment-573647070 solved the issue for me.

Closing in favor of #1743. @Imtiyaazg please open a separate issue with complete info regarding your own use case.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

isnifer picture isnifer  Â·  4Comments

aamorozov picture aamorozov  Â·  3Comments

mhyousefi picture mhyousefi  Â·  3Comments

danut-t picture danut-t  Â·  3Comments

carlosalmonte04 picture carlosalmonte04  Â·  4Comments