sentry-react-native: Detox tests timing out after setting up Performance Monitoring
Environment
How do you use Sentry? sentry.io
Which SDK and version?
"@sentry/react-native": "^3.1.1"
Steps to Reproduce
- Following instructions for Performance Monitoring
- 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
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 15 (6 by maintainers)
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:
I think this is the right solution as you typically would not want tracing in your e2e tests or dev build.
I solved this by disabling stall tracking. You can do so conditionally if you only run tests locally (but ideally this is bound to some other environment variable):
For reference, this is how you can track down a wild timer (add this to your root index.js/ts file to monkey-patch setTimeout globally in the app):
@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.
@marandaneto setting one up now - will edit this comment once up.