question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Detox tests timing out after setting up Performance Monitoring

See original GitHub issue

Environment

How do you use Sentry? sentry.io

Which SDK and version? "@sentry/react-native": "^3.1.1"

Steps to Reproduce

  1. Following instructions for Performance Monitoring
  2. Run tests on debug/release

App

function App() {
  return (
    <Provider store={store}>
      <ProviderApp />
    </Provider>
  );
}

export default wrap(App);

Config

export const ReactNavigationInstrumentation = new Sentry.ReactNavigationInstrumentation({
  routeChangeTimeoutMs: 20000,
});

if (!disableSentry) {
  Sentry.init({
    dsn: process.env.SENTRY_DSN,
    environment: process.env.ENV,
    enableNative: process.env.JEST || disableSentry ? false : true,

    autoSessionTracking: true,
    enableAutoSessionTracking: true,
    sessionTrackingIntervalMillis: 10000,
    integrations: [
      new Sentry.ReactNativeTracing({
        idleTimeout: 5000,
        routingInstrumentation: ReactNavigationInstrumentation,
        tracingOrigins: ['localhost', /^\//, /^https:\/\//],
      }),
    ],
    tracesSampleRate: 0.2, // maybe set this to 100% if __DEV__
  });
}

Expected Result

Tests should pass.

Actual Result

detox[36483] INFO:  [APP_STATUS] App synchronization debug: 
The app is busy, due to: 
         - Enqueued timers
detox[36483] INFO:  [APP_STATUS] App synchronization debug: 
The app is busy, due to: 
         - Enqueued timers
detox[36483] INFO:  [APP_STATUS] App synchronization debug: 
The app is busy, due to: 
         - Enqueued timers
detox[36483] INFO:  [APP_STATUS] App synchronization debug: 
The app is busy, due to: 
         - Enqueued timers
detox[36483] INFO:  [APP_STATUS] App synchronization debug: 
The app is busy, due to: 
         - Enqueued timers
detox[36483] INFO:  [APP_STATUS] App synchronization debug: 
The app is busy, due to: 
         - Enqueued timers
detox[36483] INFO:  [APP_STATUS] App synchronization debug: 
The app is busy, due to: 
         - Enqueued timers
detox[36483] INFO:  [APP_STATUS] App synchronization debug: 
The app is busy, due to: 
         - Enqueued timers
detox[36483] INFO:  [APP_STATUS] App synchronization debug: 
The app is busy, due to: 
         - Enqueued timers
detox[36483] INFO:  [APP_STATUS] App synchronization debug: 
The app is busy, due to: 
         - Enqueued timers
detox[36483] WARN:  [PENDING_REQUESTS] The app has not responded to the network requests below:
  (id = 80) invoke: {"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxAssertion"},"method":"assertMatcher","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"androidx.test.espresso.Espresso"},"method":"onView","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxMatcher"},"method":"matcherForTestId","args":["email-signin-input"]}}]}},{"type":"Invocation","value":{"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxMatcher"},"method":"matcherForSufficientlyVisible","args":[]}}]}

That might be the reason why the test "My Apps Tests Test using common interface" has timed out.

detox[36483] INFO:  My Apps Tests: Test using common interface [FAIL]

detox[36483] INFO:  [APP_STATUS] App synchronization debug: 
The app is busy, due to: 
         - Enqueued timers
detox[36483] ERROR: [Client.js/ERROR] The pending request #-49642 ("cleanup") has been rejected due to the following error:

The tester has not received a response within 5000ms timeout to the message:

Cleanup {
  type: 'cleanup',
  params: [Object],
  messageId: -49642
}
 FAIL  __tests__/e2e/tests/NavBarTest.tv.e2e.ts (400.848 s)

Tests work if the config is commented out

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:15 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
papa-jakecommented, Mar 4, 2022

@marandaneto This is still happening. I just spent a couple days tracking down what was causing our Detox tests to hang. After removing react native tracing instrumentation, our tests now pass successfully. I was able to track down that the timers are being set in the stall tracking: https://github.com/getsentry/sentry-react-native/blob/main/src/js/tracing/stalltracking.ts

I’d be happy to work on a PR with a bit of assistance. For now my solution is detect when it is an e2e test run and not include tracing instrumentation in my integrations.

1reaction
denissbcommented, Dec 16, 2021

I had the same issue. This is because performance tracing sets up a timer mechanism to measure the users behaviour, which breaks the sync mechanism of detox.

What helped me was to conditionally disable the tracing integration on JS side like this:

Sentry.init({
    dsn: ***,
    tracesSampleRate: 0.2,
    environment: __DEV__ ? 'dev' : 'prod',
    enableAutoSessionTracking: true,
    enableNative: process.env.JEST_WORKER_ID ? false : true,
    integrations: __DEV__
      ? undefined
      : [
          new Sentry.ReactNativeTracing({
            idleTimeout: 5000,
            routingInstrumentation,
            tracingOrigins: ['localhost', /^\//, /^https:\/\//],
        ],
  });

I think this is the right solution as you typically would not want tracing in your e2e tests or dev build.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dealing With Synchronization Issues in Tests | Detox
We are waiting too much - The test will appear to hang and fail with timeout. This happens because Detox thinks an asynchronous...
Read more >
Detox: Writing Stable Test Suites | Wix Engineering - Medium
Issue: Tests hang and time out​​ Detox manages sync between the app and test code, and waits for the app to go idle....
Read more >
React Native end-to-end testing with Detox - LogRocket Blog
Demo running end-to-end tests in React Native with Detox, an end-to-end framework for mobile apps developed by Wix.
Read more >
Detox: The unobtainable test stability (or is it?) [Breakpoint 2021]
Rotem will be talking about Detox —a gray box testing solution for mobile apps, how they fight flakiness, best practices, and their strife ......
Read more >
React Native E2E UI testing with Detox and Bitrise
Inside your React Native project folder, install Detox with the ... Now it's time to build and test our React Native apps with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found