expo / sentry-expo

MIT License
202 stars 83 forks source link

Sentry.init failed when expo.updates.enabled=false #346

Closed shibadog39 closed 1 year ago

shibadog39 commented 1 year ago

Summary

When I set enabled=false for expo.updates in expo config file (my case: app.config.ts), Sentry.init failed with TypeError: undefined is not a function.

# adb logcat result for app launching(= Sentry.init called)

I ReactNativeJS: 'Sentry Logger [log]:', 'Integration installed: ModulesLoader'
I ReactNativeJS: 'Sentry Logger [log]:', 'Unhandled promise rejections will be caught by Sentry.'
I ReactNativeJS: 'Sentry Logger [log]:', 'Integration installed: ReactNativeErrorHandlers'
I ReactNativeJS: 'Sentry Logger [log]:', 'Integration installed: Release'
I ReactNativeJS: 'Sentry Logger [log]:', 'Integration installed: InboundFilters'
I ReactNativeJS: 'Sentry Logger [log]:', 'Integration installed: FunctionToString'
I RNSentry: Starting with DSN: 'https://xxxx@xxxx.ingest.sentry.io/xxxxxx'
I RNSentry: Native Integrations '[io.sentry.UncaughtExceptionHandlerIntegration@bd15f6, io.sentry.ShutdownHookIntegration@f777df7]'
I ReactNativeJS: 'Sentry Logger [log]:', 'Integration installed: Breadcrumbs'
I ReactNativeJS: 'Sentry Logger [log]:', 'Integration installed: LinkedErrors'
I ReactNativeJS: 'Sentry Logger [log]:', 'Integration installed: Dedupe'
I ReactNativeJS: 'Sentry Logger [log]:', 'Integration installed: HttpContext'
I ReactNativeJS: 'Sentry Logger [log]:', 'Integration installed: EventOrigin'
I ReactNativeJS: 'Sentry Logger [log]:', 'Integration installed: SdkInfo'
I ReactNativeJS: 'Sentry Logger [log]:', 'Integration installed: ReactNativeInfo'
I ReactNativeJS: 'Sentry Logger [log]:', 'Integration installed: RewriteFrames'
I ReactNativeJS: 'Sentry Logger [log]:', 'Integration installed: DeviceContext'
I ReactNativeJS: 'Sentry Logger [log]:', '[ReactNativeTracing] Native frames instrumentation initialized.'
I ReactNativeJS: 'Sentry Logger [log]:', '[ReactNativeTracing] Not instrumenting route changes as routingInstrumentation has not been set.'
W ReactNativeJS: [sentry-expo] Disabling the Sentry Native SDK (all JS errors will still be reported).
W ReactNativeJS: To enable it, run 'yarn add @sentry/react-native' or 'npm install @sentry/react-native' in your project directory. To silence this warning, pass 'enableNative: false' to Sentry.init().
I ReactNativeJS: 'Sentry Logger [log]:', '[ReactNativeTracing] Native frames instrumentation initialized.'
I ReactNativeJS: 'Sentry Logger [log]:', '[ReactNativeTracing] Not instrumenting route changes as routingInstrumentation has not been set.'
E ReactNativeJS: TypeError: undefined is not a function, js engine: hermes
I ReactNativeJS: Running "main
E ReactNativeJS: Invariant Violation: "main" has not been registered. This can happen if:
E ReactNativeJS: * Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
E ReactNativeJS: * A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called., js engine: hermes

Managed or bare workflow? If you have ios/ or android/ directories in your project, the answer is bare!

managed

What platform(s) does this occur on?

Android, iOS

SDK Version (managed workflow only)

48

Environment

System: OS: macOS 12.6 Shell: 5.8.1 - /bin/zsh Binaries: Node: 18.15.0 - ~/.anyenv/envs/nodenv/versions/18.15.0/bin/node npm: 9.5.0 - ~/.anyenv/envs/nodenv/versions/18.15.0/bin/npm IDEs: Android Studio: 2022.2 AI-222.4459.24.2221.9971841 Xcode: /undefined - /usr/bin/xcodebuild npmGlobalPackages: eas-cli: 3.12.0 Expo Workflow: managed

Reproducible demo or steps to reproduce from a blank project

app.config.ts

import { ConfigContext, ExpoConfig } from 'expo/config'

export default ({ config }: ConfigContext): ExpoConfig => {
  return {
    ...config,
    updates: {
      url: 'https://u.expo.dev/{your_project_id},
      enabled: false,
    },
    ...
  }
}

App.tsx

Sentry.init({
  dsn: SENTRY_DSN,
  enableInExpoDevelopment: true,
  debug: true,
})

...
shibadog39 commented 1 year ago

resolved by adding dist to Sentry.init and update sentry-expo to 6.2.2(from 6.1.1)

import * as Application from 'expo-application'

Sentry.init({
  dsn: SENTRY_DSN,
  debug: true,
  dist: ${Application.nativeBuildVersion}
})