You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Expo集成Sentry ReactNativeTracing后触发无限循环错误求助

Expo集成Sentry ReactNativeTracing后陷入错误无限循环问题

开发了一款Expo应用,集成Sentry后,只要启用Sentry.Native.ReactNativeTracing集成,应用就会陷入错误无限循环。

相关日志信息

LOG  Sentry Logger [log]: Integration installed: ModulesLoader
 LOG  Sentry Logger [log]: Unhandled promise rejections will be caught by Sentry.
 LOG  Sentry Logger [log]: Integration installed: ReactNativeErrorHandlers
 LOG  Sentry Logger [log]: Integration installed: Release
 LOG  Sentry Logger [log]: Integration installed: InboundFilters
 LOG  Sentry Logger [log]: Integration installed: FunctionToString
 LOG  Sentry Logger [log]: Integration installed: Breadcrumbs
 LOG  Sentry Logger [log]: Integration installed: Dedupe
 LOG  Sentry Logger [log]: Integration installed: HttpContext
 LOG  Sentry Logger [log]: Integration installed: NativeLinkedErrors
 LOG  Sentry Logger [log]: Integration installed: EventOrigin
 LOG  Sentry Logger [log]: Integration installed: SdkInfo
 LOG  Sentry Logger [log]: Integration installed: ReactNativeInfo
 LOG  Sentry Logger [log]: Integration installed: DebugSymbolicator
 LOG  Sentry Logger [log]: Integration installed: RewriteFrames
 LOG  Sentry Logger [log]: [ReactNativeTracing] Native frames instrumentation initialized.
 LOG  Sentry Logger [log]: Setting idle transaction on scope. Span ID: a7bae05c7f745660
 LOG  Sentry Logger [log]: [Tracing] starting navigation transaction - Route Change
 LOG  Sentry Logger [log]: Starting heartbeat
 LOG  Sentry Logger [log]: pinging Heartbeat -> current counter: 0
 LOG  Sentry Logger [log]: [ReactNativeTracing] Starting navigation transaction "Route Change" on scope
 LOG  Sentry Logger [log]: Integration installed: ReactNativeTracing
 LOG  Sentry Logger [log]: Integration installed: ExpoManagedIntegration
 LOG  Sentry Logger [log]: Integration installed: react-navigation-v5
 LOG  Sentry Logger [log]: Integration installed: ReactNativeUserInteractionTracing
 ERROR  Sentry Logger [error]: [ReactNativeTracing] Error while fetching native frames: SentryError: Native is disabled
 LOG  Sentry Logger [log]: [Tracing] pushActivity: a8b90f2e57a3d4c4
 LOG  Sentry Logger [log]: [Tracing] new activities count 1
 LOG  Sentry Logger [log]: [Tracing] Starting 'http.client' span on transaction 'Route Change' (a7bae05c7f745660).
 LOG  Sentry Logger [log]: [Tracing] pushActivity: a9286f6ffee98601
 LOG  Sentry Logger [log]: [Tracing] new activities count 2
 LOG  Sentry Logger [log]: [Tracing] Starting 'http.client' span on transaction 'Route Change' (a7bae05c7f745660).
 LOG  Sentry Logger [log]: [Tracing] pushActivity: af6b790f32eefc62
 LOG  Sentry Logger [log]: [Tracing] new activities count 3
 LOG  Sentry Logger [log]: [Tracing] Starting 'http.client' span on transaction 'Route Change' (a7bae05c7f745660).
 LOG  Sentry Logger [log]: [Tracing] popActivity a8b90f2e57a3d4c4
 LOG  Sentry Logger [log]: [Tracing] new activities count 2
 ERROR  Sentry Logger [error]: [ReactNativeTracing] Error while fetching native frames: SentryError: Native is disabled
 LOG  Sentry Logger [log]: [Tracing] pushActivity: 8bebd01e9ff1b77a
 LOG  Sentry Logger [log]: [Tracing] new activities count 3
 LOG  Sentry Logger [log]: [Tracing] Starting 'http.client' span on transaction 'Route Change' (a7bae05c7f745660).
 LOG  Sentry Logger [log]: [Tracing] popActivity a9286f6ffee98601
 LOG  Sentry Logger [log]: [Tracing] new activities count 2
 ERROR  Sentry Logger [error]: [ReactNativeTracing] Error while fetching native frames: SentryError: Native is disabled
 LOG  Sentry Logger [log]: [Tracing] pushActivity: a68f7f0efbec741a
 LOG  Sentry Logger [log]: [Tracing] new activities count 3
 LOG  Sentry Logger [log]: [Tracing] Starting 'http.client' span on transaction 'Route Change' (a7bae05c7f745660).
 LOG  Sentry Logger [log]: [Tracing] popActivity af6b790f32eefc62
 LOG  Sentry Logger [log]: [Tracing] new activities count 2
 ERROR  Sentry Logger [error]: [ReactNativeTracing] Error while fetching native frames: SentryError: Native is disabled
 LOG  Sentry Logger [log]: [Tracing] pushActivity: 90fdf22a5d90fb8f
 LOG  Sentry Logger [log]: [Tracing] new activities count 3
 LOG  Sentry Logger [log]: [Tracing] Starting 'http.client' span on transaction 'Route Change' (a7bae05c7f745660).
 LOG  Sentry Logger [log]: [Tracing] popActivity 8bebd01e9ff1b77a
 LOG  Sentry Logger [log]: [Tracing] new activities count 2
 ERROR  Sentry Logger [error]: [ReactNativeTracing] Error while fetching native frames: SentryError: Native is disabled

已查阅Expo官方Sentry文档、Sentry官方文档及相关GitHub问题,但仍无法定位问题原因。

routingInstrumentation配置

import * as Sentry from 'sentry-expo';

// Construct a new instrumentation instance. This is needed to communicate between the integration and React
const routingInstrumentation = new Sentry.Native.ReactNavigationInstrumentation();

const Root = () => {
  const [isFetchingToken, setIsFetchingToken] = useState(true);
  const authCtx = useContext(AuthContext);

  if (isFetchingToken)
    return (
      <View>
        <Text>Loading...</Text>
      </View>
    );

  // Checking auth state, fetching token etc...

  return (
    <NavigationContainer
      ref={navigationRef}
      onReady={() => {
        // Register the navigation container with the instrumentation
        routingInstrumentation.registerNavigationContainer(navigationRef);
      }}>
      {authCtx.isAuthenticated ? <MainStackNavigator /> : <AuthNavigator />}
    </NavigationContainer>
  );
};

Sentry.init配置

Sentry.init({
  dsn: 'my-dsn',
  enableInExpoDevelopment: true,
  enableNative: true,
  debug: !isProduction, // * If `true`, Sentry will try to print out useful debugging information if something goes wrong with sending the event. Set it to `false` in production

  // * Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.
  // * We recommend adjusting this value in production.
  sampleRate: isProduction ? 0.2 : 1.0,
  tracesSampleRate: isProduction ? 0.2 : 1.0,

  integrations: [
    new Sentry.Native.ReactNativeTracing({
      routingInstrumentation,
      enableAppStartTracking: false,
      enableStallTracking: true,
      enableUserInteractionTracing: true,
      enableNativeFramesTracking: true,
    }),
  ],
});

也尝试过使用Sentry.Native.init,但问题依旧,仍会出现无限循环。


内容的提问来源于stack exchange,提问作者Máté Antal

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.05 13:44:54