getsentry / sentry-react-native

Official Sentry SDK for React Native
https://sentry.io
MIT License
1.57k stars 337 forks source link

Detox and Sentry.init integrations array cause timeout #4088

Open estiventhneira opened 1 month ago

estiventhneira commented 1 month ago

OS:

Platform:

SDK:

SDK version: ^5.31.1

react-native version: 0.71.11

Are you using Expo?

Are you using sentry.io or 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://...@sentry.io/...'
  // 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:

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:

krystofwoldrich commented 1 month ago

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?

estiventhneira commented 1 month ago

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