sentry-react-native icon indicating copy to clipboard operation
sentry-react-native copied to clipboard

Detox and Sentry.init integrations array cause timeout

Open estiventhneira opened this issue 1 year ago • 2 comments

OS:

  • [ ] Windows
  • [ ] MacOS
  • [ x] Linux

Platform:

  • [ ] iOS
  • [ x] Android

SDK:

  • [ x] @sentry/react-native (>= 1.0.0)
  • [ ] react-native-sentry (<= 0.43.2)

SDK version: ^5.31.1

react-native version: 0.71.11

Are you using Expo?

  • [ ] Yes
  • [x ] No

Are you using sentry.io or on-premise?

  • [x ] sentry.io (SaaS)
  • [ ] on-premise

If you are using sentry.io, please post a link to your issue so we can take a look:

[Link to issue]

Configuration:

(@sentry/react-native)

Sentry.init({
  dsn:
  enableNative: process.env.JEST ? false : true,
  attachScreenshot: true, 
  environment: __DEV__ ? "dev" : "prod",
  enableAutoSessionTracking: true,
  tracesSampleRate: 0.3,
  _experiments: {
    replaysSessionSampleRate: 0.1,
    replaysOnErrorSampleRate: 1.0,
  },
  integrations: [
    new Sentry.ReactNativeTracing({
      tracingOrigins: ["/.*.amazonaws.com.*/"],
    }),
    Sentry.mobileReplayIntegration({
      maskAllText: false,
      maskAllImages: false,
    }),
  ],
  beforeSend: async (event, hint) => {
    const error = hint.originalException;
    if (
      error &&
      error.message &&
      error.message.match(/Carton does not match any of the queued items/i)
    ) {
      return null;
    }
    console.log("Sentry event to send", event);
    await captureScreenshot(); // Capture a screenshot immediately
    if (attachments.length > 0) {
      console.log("SENTRY ATTACHMENTS", attachments);
      hint.attachments = attachments;

      // Clear the captured screenshots after attaching to the event
      capturedScreenshots = [];
      attachments = [];
    }
    return event;
  }
});

or

(react-native-sentry)

Sentry.config(
  'https://[email protected]/...'
  // other options
 ).install();

I have the following issue:

When trying to run detox test it get stuck waiting for a connection with sentry than makes timeout error:

13:50:39.972 detox[6080] i An error occurred while waiting for the app to become ready. Waiting for disconnection... error: The pending request #-1000 ("isReady") has been rejected due to the following error:

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

13:50:45.081 detox[6080] i 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:

thrown: "Exceeded timeout of 120000 ms for a hook. Add a timeout value to this test to increase the timeout, if this is a long-running test. See https://jestjs.io/docs/api#testname-fn-timeout."

Steps to reproduce:

  • Sentry.init with integrations array
  • Build and Run Detox test

Actual result:

Get timeout error

Expected result:

Be able to run the tests without commenting integrations arrays which is a workaround for it

this is related with integrations array as the solutions here works 13:50:39.972 detox[6080] i An error occurred while waiting for the app to become ready. Waiting for disconnection... error: The pending request #-1000 ("isReady") has been rejected due to the following error:

estiventhneira avatar Sep 13 '24 05:09 estiventhneira

Hi @estiventhneira, thank you for the message,

would you be able to share a reproducible example we could debug?


The ReactNativeTracing tracing integration is added by default when tracesSampleRate is set, so setting in integration array should not make a difference.

Does anything changes when only omitting the Replay integration?

krystofwoldrich avatar Sep 13 '24 10:09 krystofwoldrich

I have to disabled tracesSampleRate too to avoid the error of detox getting stuck

estiventhneira avatar Sep 13 '24 14:09 estiventhneira

@estiventhneira Would you be able to share a sample app with Detox tests and Sentry which we could investigate?

krystofwoldrich avatar Dec 02 '24 16:12 krystofwoldrich

We've started using Detox in our sample app and we have not encountered any timeouts

  • https://github.com/getsentry/sentry-react-native/pull/4526

krystofwoldrich avatar Feb 13 '25 21:02 krystofwoldrich