Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to send test event to Sentry from React Native using Expo #294

Closed
juicemia opened this issue Oct 24, 2022 · 15 comments
Closed

Unable to send test event to Sentry from React Native using Expo #294

juicemia opened this issue Oct 24, 2022 · 15 comments
Labels

Comments

@juicemia
Copy link

Summary

Followed the documentation here after direct usage of @sentry/react-native stopped working in my Expo app.

I stripped everything and followed that documentation to get sentry-expo installed and working. I'm just trying to test if an event gets to Sentry correctly which is why I have it enabled in development.

When I load the app with the above configuration I see the following in the logs:

 LOG  Sentry Logger [log]: Unhandled promise rejections will be caught by Sentry.
 LOG  Sentry Logger [log]: Integration installed: ReactNativeErrorHandlers
 ERROR  SentryError: Native Client is not available, can't start on native.
 ERROR  Invariant Violation: "main" has not been registered. This can happen if:
* 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.
* A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called.

When I set enableNative: false I see the following logs (ignore TESTING SENTRY FROM APP that's just my test error):

 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: ExpoManagedIntegration
 LOG  Sentry Logger [log]: Integration installed: RewriteFrames
 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: LinkedErrors
 LOG  Sentry Logger [log]: Integration installed: Dedupe
 LOG  Sentry Logger [log]: Integration installed: HttpContext
 LOG  Sentry Logger [log]: Integration installed: EventOrigin
 LOG  Sentry Logger [log]: Integration installed: SdkInfo
 LOG  Sentry Logger [log]: Integration installed: DebugSymbolicator
 ERROR  Error: TESTING SENTRY FROM APP

This error is located at:
    in App (created by RootApp)
    in ReactNativeProfiler (created by RootApp)
    in RCTView (created by View)
    in View (created by __Sentry.TouchEventBoundary)
    in __Sentry.TouchEventBoundary (created by RootApp)
    in RootApp (created by ExpoRoot)
    in ExpoRoot
    in RCTView (created by View)
    in View (created by AppContainer)
    in DevAppContainer (created by AppContainer)
    in RCTView (created by View)
    in View (created by AppContainer)
    in AppContainer
    in main(RootComponent)
 ERROR  Error: TESTING SENTRY FROM APP

This error is located at:
    in App (created by RootApp)
    in ReactNativeProfiler (created by RootApp)
    in RCTView (created by View)
    in View (created by __Sentry.TouchEventBoundary)
    in __Sentry.TouchEventBoundary (created by RootApp)
    in RootApp (created by ExpoRoot)
    in ExpoRoot
    in RCTView (created by View)
    in View (created by AppContainer)
    in DevAppContainer (created by AppContainer)
    in RCTView (created by View)
    in View (created by AppContainer)
    in AppContainer
    in main(RootComponent)
 WARN  Sentry Logger [warn]: [SdkInfo] Native SDK Info retrieval failed...something could be wrong with your Sentry installation:
 WARN  Sentry Logger [warn]: [SentryError: Native is disabled]
 WARN  Sentry Logger [warn]: Event was skipped as native SDK is not enabled.

In either case, I don't see the errors actually making it to Sentry.

I tested the DSN itself using sentry-cli and messages show up in that case, so that's ruled out.

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?

iOS

SDK Version (managed workflow only)

expo@46.0.16

Environment

  expo-env-info 1.0.5 environment info:
    System:
      OS: macOS 12.6
      Shell: 5.8.1 - /bin/zsh
    Binaries:
      Node: 16.16.0 - ~/.nvm/versions/node/v16.16.0/bin/node
      Yarn: 1.22.19 - ~/.nvm/versions/node/v16.16.0/bin/yarn
      npm: 8.15.0 - ~/.nvm/versions/node/v16.16.0/bin/npm
    Managers:
      CocoaPods: 1.11.3 - /usr/local/bin/pod
    SDKs:
      iOS SDK:
        Platforms: DriverKit 21.4, iOS 16.0, macOS 12.3, tvOS 16.0, watchOS 9.0
    IDEs:
      Xcode: 14.0.1/14A400 - /usr/bin/xcodebuild
    npmPackages:
      expo: ^46.0.0 => 46.0.16
      react: 18.0.0 => 18.0.0
      react-dom: 18.0.0 => 18.0.0
      react-native: 0.69.6 => 0.69.6
      react-native-web: ~0.18.7 => 0.18.9
    npmGlobalPackages:
      eas-cli: 0.56.0
      expo-cli: 6.0.2
    Expo Workflow: managed

Reproducible demo or steps to reproduce from a blank project

  1. npx create-expo-app sentry-expo-test
  2. cd sentry-expo-test
  3. npx expo install expo-application expo-constants expo-device expo-updates @sentry/react-native
  4. npm run start
  5. Open the app on a phone using the QR code

package.json:

{
  "name": "sentry-expo-test",
  "version": "1.0.0",
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web"
  },
  "dependencies": {
    "expo": "~46.0.16",
    "expo-status-bar": "~1.4.0",
    "react": "18.0.0",
    "react-native": "0.69.6",
    "sentry-expo": "~5.0.0",
    "expo-application": "~4.2.2",
    "expo-constants": "~13.2.4",
    "expo-device": "~4.3.0",
    "expo-updates": "~0.14.6",
    "@sentry/react-native": "4.2.2"
  },
  "devDependencies": {
    "@babel/core": "^7.12.9"
  },
  "private": true
}

App.js:

import { StatusBar } from 'expo-status-bar';
import { StyleSheet, Text, View } from 'react-native';

import * as Sentry from 'sentry-expo';

Sentry.init({
  dsn: 'https://4b0b75939d3a42eea1785eb6fce3d641@o1311662.ingest.sentry.io/4503994031341568',
  tracesSampleRate: 0.1,
  enableNative: true,
  enableInExpoDevelopment: true,
  debug: true
});

export default function App() {
  Sentry.Native.captureException(new Error('TESTING FROM SENTRY APP'));

  return (
    <View style={styles.container}>
      <Text>Open up App.js to start working on your app!</Text>
      <StatusBar style="auto" />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
});
@juicemia
Copy link
Author

I originally opened this issue with Sentry and they recommended I ask for help here.

@aeife
Copy link

aeife commented Oct 28, 2022

I'm also having issues with sentry-expo since SDK 46. Errors are not delivered to sentry. This happens also for standalone app builds.

What is weird is that downgrading expo-sentry to 4.2.0 is working for me and also some other devs reported this here: #243

Update:
I just investigated my issue further and I was missing the @sentry/react-native dependency in my package.json. After adding that and creating a new build sentry receives events again. So anyone using the downgrade workaround should probably check that. Seems like the need for this dependency only became crucial with the latest sdk update. Still does not help with the unavailable SDK in expo go but thought I add my findings here anyway for anyone that searches for it.

@juicemia
Copy link
Author

@aeife I have the @sentry/react-native dependency in my package.json, but I'm going to try downgrading like you suggested. I'll report back here with how it goes.

@juicemia
Copy link
Author

@aeife downgrading like you suggested didn't fix it. All it did was make the app endlessly error with logs like this:

 ERROR  Sentry Logger [error]: Error while triggering instrumentation handler.
Type: xhr
Name: _xhrBreadcrumb
Error: [SentryError: Native Client is not available, can't start on native.]
 ERROR  Sentry Logger [error]: Error while triggering instrumentation handler.
Type: xhr
Name: _xhrBreadcrumb
Error: [SentryError: Native Client is not available, can't start on native.]
 ERROR  Sentry Logger [error]: Error while triggering instrumentation handler.
Type: xhr
Name: _xhrBreadcrumb
Error: [SentryError: Native Client is not available, can't start on native.]
 ERROR  Sentry Logger [error]: Error while triggering instrumentation handler.
Type: xhr
Name: _xhrBreadcrumb
Error: [SentryError: Native Client is not available, can't start on native.]
 ERROR  Sentry Logger [error]: Error while triggering instrumentation handler.
Type: xhr
Name: _xhrBreadcrumb
Error: [SentryError: Native Client is not available, can't start on native.]

@marandaneto
Copy link

marandaneto commented Nov 5, 2022

The error log Native Client is not available, can't start on native. means that the Native bridges (Android and iOS) were not able to be inited.
That could be either caching on your end or something with the Expo and Sentry setup, if I install the Sentry RN SDK directly in a fresh app, everything works out normally.
Likely related to #285 as well

If you are using RN >= 0.69, try to check this out: https://docs.sentry.io/platforms/react-native/troubleshooting/#react-native-069-and-higher

@stesvis
Copy link

stesvis commented Nov 14, 2022

I am getting this error too on "expo": "^47.0.0" and "sentry-expo": "~5.0.0".

Whenever I execute

Sentry.Native.captureException(new Error("Sentry test...");

I get the

Sentry Logger [warn]:, Event was skipped as native SDK is not enabled.
at node_modules@sentry\utils\cjs\logger.js:null in consoleSandbox$argument_0
at node_modules@sentry\utils\cjs\logger.js:null in consoleSandbox
at node_modules@sentry\utils\cjs\logger.js:null in name
at node_modules@sentry\react-native\dist\js\wrapper.js:null in __awaiter$argument_3
at node_modules\tslib\tslib.js:null in
at node_modules\promise\setimmediate\core.js:null in tryCallTwo
at node_modules\promise\setimmediate\core.js:null in doResolve
at node_modules\promise\setimmediate\core.js:null in Promise
at node_modules\tslib\tslib.js:null in __awaiter
at node_modules@sentry\react-native\dist\js\wrapper.js:null in NATIVE.sendEnvelope
at node_modules@sentry\react-native\dist\js\transports\native.js:null in _buffer.add$argument_0
at node_modules@sentry\utils\cjs\promisebuffer.js:null in add
at node_modules@sentry\react-native\dist\js\transports\native.js:null in NativeTransport#send
at node_modules@sentry\core\cjs\baseclient.js:null in BaseClient#_sendEnvelope
at node_modules@sentry\core\cjs\baseclient.js:null in BaseClient#sendEvent
at node_modules@sentry\core\cjs\baseclient.js:null in _prepareEvent.then.then$argument_0
at node_modules@sentry\utils\cjs\syncpromise.js:null in
at node_modules@sentry\utils\cjs\syncpromise.js:null in cachedHandlers.forEach$argument_0
at node_modules@sentry\utils\cjs\syncpromise.js:null in _executeHandlers
at node_modules@sentry\utils\cjs\syncpromise.js:null in _setResult
at node_modules@sentry\utils\cjs\syncpromise.js:null in _resolve
at node_modules@sentry\utils\cjs\syncpromise.js:null in
at node_modules@sentry\utils\cjs\syncpromise.js:null in cachedHandlers.forEach$argument_0
at node_modules@sentry\utils\cjs\syncpromise.js:null in _executeHandlers
at node_modules@sentry\utils\cjs\syncpromise.js:null in _setResult
at node_modules@sentry\utils\cjs\syncpromise.js:null in _resolve
at node_modules@sentry\utils\cjs\syncpromise.js:null in
at node_modules@sentry\utils\cjs\syncpromise.js:null in cachedHandlers.forEach$argument_0
at node_modules@sentry\utils\cjs\syncpromise.js:null in _executeHandlers
at node_modules@sentry\utils\cjs\syncpromise.js:null in _setResult
at node_modules@sentry\utils\cjs\syncpromise.js:null in _resolve
at node_modules@sentry\utils\cjs\syncpromise.js:null in
at node_modules@sentry\utils\cjs\syncpromise.js:null in cachedHandlers.forEach$argument_0
at node_modules@sentry\utils\cjs\syncpromise.js:null in _executeHandlers
at node_modules@sentry\utils\cjs\syncpromise.js:null in _setResult
at node_modules@sentry\utils\cjs\syncpromise.js:null in _resolve
at node_modules@sentry\utils\cjs\syncpromise.js:null in
at node_modules@sentry\utils\cjs\syncpromise.js:null in cachedHandlers.forEach$argument_0
at node_modules@sentry\utils\cjs\syncpromise.js:null in _executeHandlers
at node_modules@sentry\utils\cjs\syncpromise.js:null in _setResult
at node_modules@sentry\utils\cjs\syncpromise.js:null in _resolve
at node_modules@sentry\utils\cjs\syncpromise.js:null in
at node_modules@sentry\utils\cjs\syncpromise.js:null in cachedHandlers.forEach$argument_0
at node_modules@sentry\utils\cjs\syncpromise.js:null in _executeHandlers
at node_modules@sentry\utils\cjs\syncpromise.js:null in _setResult
at node_modules@sentry\utils\cjs\syncpromise.js:null in _resolve
at node_modules@sentry\utils\cjs\syncpromise.js:null in
at node_modules@sentry\utils\cjs\syncpromise.js:null in cachedHandlers.forEach$argument_0
at node_modules@sentry\utils\cjs\syncpromise.js:null in _executeHandlers
at node_modules@sentry\utils\cjs\syncpromise.js:null in _setResult
at node_modules@sentry\utils\cjs\syncpromise.js:null in _resolve
at node_modules@sentry\utils\cjs\syncpromise.js:null in
at node_modules@sentry\utils\cjs\syncpromise.js:null in cachedHandlers.forEach$argument_0
at node_modules@sentry\utils\cjs\syncpromise.js:null in _executeHandlers
at node_modules@sentry\utils\cjs\syncpromise.js:null in _setResult
at node_modules@sentry\utils\cjs\syncpromise.js:null in _resolve
at node_modules@sentry\utils\cjs\syncpromise.js:null in
at node_modules@sentry\utils\cjs\syncpromise.js:null in cachedHandlers.forEach$argument_0
at node_modules@sentry\utils\cjs\syncpromise.js:null in _executeHandlers
at node_modules@sentry\utils\cjs\syncpromise.js:null in _setResult
at node_modules@sentry\utils\cjs\syncpromise.js:null in _resolve
at node_modules@sentry\utils\cjs\syncpromise.js:null in
at node_modules@sentry\utils\cjs\syncpromise.js:null in cachedHandlers.forEach$argument_0
at node_modules@sentry\utils\cjs\syncpromise.js:null in _executeHandlers
at node_modules@sentry\utils\cjs\syncpromise.js:null in _setResult

  • ... 2 more stack frames from framework internals

I am on android and I applied the workaround linked above in the comments...

Any way to make it work again?

@cgav
Copy link

cgav commented Nov 17, 2022

I posted a solution that works for me here: #285 (comment)

@hiddenist
Copy link

hiddenist commented Dec 14, 2022

Above reply did not work, but this does: #285 (comment)

I also had some typescript issues until I removed @sentry/react-native from my package.json and used it as a transient dependency through sentry-expo@4.2.0

@EmanuilM
Copy link

EmanuilM commented Jan 4, 2023

I am getting this error too on "expo": "^47.0.0" and "sentry-expo": "~5.0.0".

Whenever I execute

Sentry.Native.captureException(new Error("Sentry test...");

I get the

Sentry Logger [warn]:, Event was skipped as native SDK is not enabled.
at node_modules@sentry\utils\cjs\logger.js:null in consoleSandbox$argument_0
at node_modules@sentry\utils\cjs\logger.js:null in consoleSandbox
at node_modules@sentry\utils\cjs\logger.js:null in name
at node_modules@sentry\react-native\dist\js\wrapper.js:null in __awaiter$argument_3
at node_modules\tslib\tslib.js:null in
at node_modules\promise\setimmediate\core.js:null in tryCallTwo
at node_modules\promise\setimmediate\core.js:null in doResolve
at node_modules\promise\setimmediate\core.js:null in Promise
at node_modules\tslib\tslib.js:null in __awaiter
at node_modules@sentry\react-native\dist\js\wrapper.js:null in NATIVE.sendEnvelope
at node_modules@sentry\react-native\dist\js\transports\native.js:null in _buffer.add$argument_0
at node_modules@sentry\utils\cjs\promisebuffer.js:null in add
at node_modules@sentry\react-native\dist\js\transports\native.js:null in NativeTransport#send
at node_modules@sentry\core\cjs\baseclient.js:null in BaseClient#_sendEnvelope
at node_modules@sentry\core\cjs\baseclient.js:null in BaseClient#sendEvent
at node_modules@sentry\core\cjs\baseclient.js:null in _prepareEvent.then.then$argument_0
at node_modules@sentry\utils\cjs\syncpromise.js:null in
at node_modules@sentry\utils\cjs\syncpromise.js:null in cachedHandlers.forEach$argument_0
at node_modules@sentry\utils\cjs\syncpromise.js:null in _executeHandlers
at node_modules@sentry\utils\cjs\syncpromise.js:null in _setResult
at node_modules@sentry\utils\cjs\syncpromise.js:null in _resolve
at node_modules@sentry\utils\cjs\syncpromise.js:null in
at node_modules@sentry\utils\cjs\syncpromise.js:null in cachedHandlers.forEach$argument_0
at node_modules@sentry\utils\cjs\syncpromise.js:null in _executeHandlers
at node_modules@sentry\utils\cjs\syncpromise.js:null in _setResult
at node_modules@sentry\utils\cjs\syncpromise.js:null in _resolve
at node_modules@sentry\utils\cjs\syncpromise.js:null in
at node_modules@sentry\utils\cjs\syncpromise.js:null in cachedHandlers.forEach$argument_0
at node_modules@sentry\utils\cjs\syncpromise.js:null in _executeHandlers
at node_modules@sentry\utils\cjs\syncpromise.js:null in _setResult
at node_modules@sentry\utils\cjs\syncpromise.js:null in _resolve
at node_modules@sentry\utils\cjs\syncpromise.js:null in
at node_modules@sentry\utils\cjs\syncpromise.js:null in cachedHandlers.forEach$argument_0
at node_modules@sentry\utils\cjs\syncpromise.js:null in _executeHandlers
at node_modules@sentry\utils\cjs\syncpromise.js:null in _setResult
at node_modules@sentry\utils\cjs\syncpromise.js:null in _resolve
at node_modules@sentry\utils\cjs\syncpromise.js:null in
at node_modules@sentry\utils\cjs\syncpromise.js:null in cachedHandlers.forEach$argument_0
at node_modules@sentry\utils\cjs\syncpromise.js:null in _executeHandlers
at node_modules@sentry\utils\cjs\syncpromise.js:null in _setResult
at node_modules@sentry\utils\cjs\syncpromise.js:null in _resolve
at node_modules@sentry\utils\cjs\syncpromise.js:null in
at node_modules@sentry\utils\cjs\syncpromise.js:null in cachedHandlers.forEach$argument_0
at node_modules@sentry\utils\cjs\syncpromise.js:null in _executeHandlers
at node_modules@sentry\utils\cjs\syncpromise.js:null in _setResult
at node_modules@sentry\utils\cjs\syncpromise.js:null in _resolve
at node_modules@sentry\utils\cjs\syncpromise.js:null in
at node_modules@sentry\utils\cjs\syncpromise.js:null in cachedHandlers.forEach$argument_0
at node_modules@sentry\utils\cjs\syncpromise.js:null in _executeHandlers
at node_modules@sentry\utils\cjs\syncpromise.js:null in _setResult
at node_modules@sentry\utils\cjs\syncpromise.js:null in _resolve
at node_modules@sentry\utils\cjs\syncpromise.js:null in
at node_modules@sentry\utils\cjs\syncpromise.js:null in cachedHandlers.forEach$argument_0
at node_modules@sentry\utils\cjs\syncpromise.js:null in _executeHandlers
at node_modules@sentry\utils\cjs\syncpromise.js:null in _setResult
at node_modules@sentry\utils\cjs\syncpromise.js:null in _resolve
at node_modules@sentry\utils\cjs\syncpromise.js:null in
at node_modules@sentry\utils\cjs\syncpromise.js:null in cachedHandlers.forEach$argument_0
at node_modules@sentry\utils\cjs\syncpromise.js:null in _executeHandlers
at node_modules@sentry\utils\cjs\syncpromise.js:null in _setResult
at node_modules@sentry\utils\cjs\syncpromise.js:null in _resolve
at node_modules@sentry\utils\cjs\syncpromise.js:null in
at node_modules@sentry\utils\cjs\syncpromise.js:null in cachedHandlers.forEach$argument_0
at node_modules@sentry\utils\cjs\syncpromise.js:null in _executeHandlers
at node_modules@sentry\utils\cjs\syncpromise.js:null in _setResult

  • ... 2 more stack frames from framework internals

I am on android and I applied the workaround linked above in the comments...

Any way to make it work again?

Downgrade sentry-expo to "~4.2.0" and expo to "~46.0.17". It works fine for me

@rahmanharoon
Copy link

Did you find any solution for this?

@Adr1anPopescu
Copy link

Adr1anPopescu commented Mar 3, 2023

Any update here? I mean without downgrade the versions

@hueter
Copy link

hueter commented Mar 8, 2023

I found the docs said

Native crash reporting is not available in Expo Go, it is only available in standalone builds or development builds.

So I had to actually do an EAS build with my test error, download the binary, drop it into the simulator, and then trigger the error. Then it actually showed up in Sentry.

I think the enableInExpoDevelopment is kind of misleading since it doesn't work in Expo Go.

@github-actions
Copy link

github-actions bot commented May 7, 2023

This issue is stale because it has been open for 60 days with no activity. If there is no activity in the next 7 days, the issue will be closed.

@github-actions github-actions bot added the stale label May 7, 2023
@github-actions
Copy link

This issue was closed because it has been inactive for 7 days since being marked as stale. Please open a new issue if you believe you are encountering a related problem.

@cabe56
Copy link

cabe56 commented Jun 17, 2023

Leaving my context here jic anyone else is facing the same issue. I'm running managed Expo 47 (no bare/eject; just vanilla Expo). I had the same issue many have mentioned that events weren't reaching my Sentry (SaaS; not self-hosted) instance.

Dependencies

expo=47.0.14
sentry-expo=4.2.0
@sentry/react-native=3.1.1

Caveats:

  • Had to downgrade sentry-expo to 4.2.0, versions 5 and 6 just didn't work (as other have pointed out)
  • Installed all dependencies listed in Expo docs: https://docs.expo.dev/guides/using-sentry/#installation
    • Including expo-application seems to have expanded data available in Sentry events
  • Imported from sentry-expo, not @sentry/react-native
  • Installed @sentry/react-native as a dep with the matching version of sentry-expo (3.1.1)
  • Changing/adding @sentry/react-native dependency required generating a build, OTA update without building crashed my app

Update

Upgrading sentry-expo and @sentry/react-native worked after building.

expo=47.0.14
sentry-expo=6.0.0
@sentry/react-native=4.9.0

This requires installing @sentry/react-native as a dependency and building again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests