FBSSystemService reported failure without an error, possibly because the app is not currently running

Viewed 89

I am running this command:

detox test -c ios.sim.debug --loglevel verbose

And this is my build configuration:

xcodebuild -workspace ios/PocketGeek.xcworkspace -configuration Debug -scheme PocketGeek -sdk iphonesimulator -derivedDataPath ios/build EXCLUDED_ARCHS=arm64

But my project gets this error:

Detox[53454] INFO:  [test.js] DETOX_CONFIGURATION="ios.sim.debug" DETOX_LOGLEVEL="verbose" DETOX_REPORT_SPECS=true DETOX_START_TIMESTAMP=1658788416758 DETOX_USE_CUSTOM_LOGGER=true jest --config e2e/config.json --testNamePattern '^((?!:android:).)*$' e2e
detox[53455] DEBUG: [WSS_CREATE] Detox server listening on localhost:64782...
detox[53455] DEBUG: [WSS_CONNECTION, #64783] registered a new connection.
detox[53455] DEBUG: [EXEC_CMD, #0] applesimutils --list --byType "iPhone 12"
detox[53455] DEBUG: [EXEC_CMD, #1] applesimutils --list --byId F947CB36-9A5E-4D82-84FF-26DCED392070 --maxResults 1
detox[53455] DEBUG: [EXEC_CMD, #2] /usr/bin/xcrun simctl terminate F947CB36-9A5E-4D82-84FF-26DCED392070 com.pocketgeek.ios
detox[53455] DEBUG: [EXEC_TRY, #2] Terminating com.pocketgeek.ios...
detox[53455] DEBUG: [EXEC_TRY, #2] Terminating com.pocketgeek.ios...
detox[53455] ERROR: [EXEC_FAIL, #2] "/usr/bin/xcrun simctl terminate F947CB36-9A5E-4D82-84FF-26DCED392070 com.pocketgeek.ios" failed with error = ChildProcessError: Command failed: /usr/bin/xcrun simctl terminate F947CB36-9A5E-4D82-84FF-26DCED392070 com.pocketgeek.ios
An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=3):
Application termination failed.
FBSSystemService reported failure without an error, possibly because the app is not currently running.
 `/usr/bin/xcrun simctl terminate F947CB36-9A5E-4D82-84FF-26DCED392070 com.pocketgeek.ios` (exited with error code 3) (code=3), stdout and stderr:

detox[53455] ERROR: [EXEC_FAIL, #2] 
detox[53455] ERROR: [EXEC_FAIL, #2] An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=3):
Application termination failed.
FBSSystemService reported failure without an error, possibly because the app is not currently running.

detox[53455] ERROR: Command failed: /usr/bin/xcrun simctl terminate F947CB36-9A5E-4D82-84FF-26DCED392070 com.pocketgeek.ios
An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=3):
Application termination failed.
FBSSystemService reported failure without an error, possibly because the app is not currently running.
 `/usr/bin/xcrun simctl terminate F947CB36-9A5E-4D82-84FF-26DCED392070 com.pocketgeek.ios` (exited with error code 3)
detox[53455] INFO:  Example is assigned to undefined
detox[53455] INFO:  Example: should have welcome screen
detox[53455] INFO:  Example: should have welcome screen [SKIPPED]
detox[53455] INFO:  Example: should show hello screen after tap
detox[53455] INFO:  Example: should show hello screen after tap [SKIPPED]
detox[53455] INFO:  Example: should show world screen after tap
detox[53455] INFO:  Example: should show world screen after tap [SKIPPED]

detox[53455] DEBUG: [WSS_CLOSE] Detox server has been closed gracefully
detox[53454] ERROR: [cli.js] Command failed: jest --config e2e/config.json --testNamePattern '^((?!:android:).)*$' e2e

This is my detoxrc.json file in case someone wants to see my current configuration for Detox

{
  "testRunner": "jest",
  "runnerConfig": "e2e/config.json",
  "skipLegacyWorkersInjection": true,
  "apps": {

    "ios.release": {
      "type": "ios.app",
      "binaryPath": "ios/build/Build/Products/Release-iphonesimulator/PocketGeek.app",
      "build": "xcodebuild -workspace ios/PocketGeek.xcworkspace -configuration Release -scheme PocketGeek -sdk iphonesimulator -derivedDataPath ios/build EXCLUDED_ARCHS=arm64"
    },
    "ios.debug": {
      "type": "ios.app",
      "binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/PocketGeek.app",
      "build": "xcodebuild -workspace ios/PocketGeek.xcworkspace -configuration Debug -scheme PocketGeek -sdk iphonesimulator -derivedDataPath ios/build EXCLUDED_ARCHS=arm64"
    },
    "android": {
      "type": "android.apk",
      "binaryPath": "SPECIFY_PATH_TO_YOUR_APP_BINARY"
    }
  },
  "devices": {
    "simulator": {
      "type": "ios.simulator",
      "device": {
        "type": "iPhone 12"
      }
    },
    "emulator": {
      "type": "android.emulator",
      "device": {
        "avdName": "Pixel_3a_API_30_x86"
      }
    }
  },
  "configurations": {
    "ios.sim.release": {
      "device": "simulator",
      "app": "ios.release"
    },
    "ios.sim.debug": {
      "device": "simulator",
      "app": "ios.debug"
    },
    "android": {
      "device": "emulator",
      "app": "android"
    }
  }
}

We are trying to run detox test and make the simulator to work but it seems nothing seems to work. Any advice if someone has faced this issue?

Thanks

1 Answers

This looks like a known issue which was resolved in Detox Release 19.4.3 through this PR with the workaround captured below.

async terminate(udid, bundleId) {
    const statusLogs = {
      trying: `Terminating ${bundleId}...`,
      successful: `${bundleId} terminated`
    };


    try {
      await this._execSimctl({
        cmd: `terminate ${udid} ${bundleId}`,
        statusLogs: statusLogs,
        silent: true
      });
    } catch (err) {
      // Since we have no convenient way to check whether the app is currently running or not, we might execute this
      // command (terminate) even if the app is not currently running, or even installed.
      // We have encountered some case where the following error is thrown in a case where the app did not run:
      // ```
      // An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=3):
      // Application termination failed.
      // FBSSystemService reported failure without an error, possibly because the app is not currently running.
      // ```
      // This workaround is done to ignore the error above, as we do not care if the app was running before, we just
      // want to make sure it isn't now.
      if (err.code === 3 && err.stderr.includes(`the app is not currently running`)) {
        return;
      }


      throw err;
    }
  }

Reference: https://github.com/wix/Detox/blob/9229e64ec8f95574aab5beeeb4fa6bcc84844f69/detox/src/devices/common/drivers/ios/tools/AppleSimUtils.js#L239-L255

So in the event terminate command is run and the error thrown contains the text 'the app is not currently running' this should be handled. What version of Detox are you using?

I've just opened a similar issue but with a subtly different error message The operation couldn’t be completed. found nothing to terminate when testing against XCode14 iPadOS16 BETA. https://github.com/wix/Detox/issues/3518

Related