Weird startup error when using Sentry

  1. SDK Version: 46
  2. Platforms: Android and iOS (haven’t tested web)

I’m trying to use Sentry in my Expo managed workflow. I’ve followed the guide here, which includes calling Sentry.init() from App.tsx:

Sentry.init({
  dsn: "https://blahblah@blahblah.ingest.sentry.io/blahblah",
  enableInExpoDevelopment: true,
  debug: true,
});

For some reason, calling Sentry.init() is leading to a crash on load. In debug mode (in expo go) I get the following error, which seems completely unrelated:

Objects are not valid as a React child (found: object with keys {_U, _V, _W, _X}).

This error is in a hook provided by expo-fonts, not in one of my own hooks. Additionally, when I remove the code calling Sentry.init() (or set enableInExpoDevelopment: false, the error goes away and everything works normally. Of course this means that I can’t have Sentry in production which is a problem.

Does anyone know what could be causing this strange issue? I’ve double checked that my DSN and organization/project name are correct, and that I’ve followed the guide to a T.

Hi @wohlers.w

I’m pretty sure it should go outside of any hooks/components at the top of the file.

Give that a try and let us know how it goes.

Hi @wodin thanks for the response. It’s currently in another file that gets imported by App.tsx, but when I move it to the top of App.tsx I also get a strange error related to one of my hooks. It seems completely unrelated to Sentry, but the error disappears once I comment out Sentry.init(). It seems to have something to do with Suspense (I’m also using Jotai for state management).

Basically calling Sentry.init() is causing stateful hooks to bug out. I was able to improve the problem by removing an unnecessary <Suspense> component that I had, but it still hasn’t fixed the problem entirely.

I’m just not understanding how calling a synchronous function could possibly impact useState/state management hooks.

Actually, I forcefully fixed the other error I was having when calling Sentry.init() from App.tsx, now I’m getting the same error. Here’s a screenshot of it

I’m not sure what you mean by “forcefully fixed the other error”.

I think the error looks to me like it’s trying to render a promise instead of a component.

Right, but the error is in FontHooks.js, which is in the expo-font package, not in my own code. And it stops when I comment out Sentry.init(). What could explain that? Why would calling Sentry.init cause an error inside expo-font?