expo / sentry-expo

MIT License
203 stars 83 forks source link

core.addTracingExtensions() is not a function #332

Closed MaxAst closed 1 year ago

MaxAst commented 1 year ago

Summary

I followed the installation instructions in the Using Sentry guide, but my app crashes right away with an uncaught error undefined is not a function. The source of the error seems to be the core.addTracingExtension() function from the @sentry/internal package. I haven't found any other GH issues or Discord discussions citing this error.

IMG_1117

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)

48.0.11

Environment

expo-env-info 1.0.5 environment info: System: OS: macOS 13.2 Shell: 5.8.1 - /bin/zsh Binaries: Node: 18.16.0 - ~/.nvm/versions/node/v18.16.0/bin/node Yarn: 1.22.19 - ~/.yarn/bin/yarn npm: 9.5.1 - ~/.nvm/versions/node/v18.16.0/bin/npm Watchman: 2023.02.13.00 - /opt/homebrew/bin/watchman Managers: CocoaPods: 1.11.3 - /opt/homebrew/bin/pod SDKs: iOS SDK: Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1 IDEs: Android Studio: 2022.2 AI-222.4459.24.2221.9971841 Xcode: 14.2/14C18 - /usr/bin/xcodebuild npmGlobalPackages: eas-cli: 3.11.0 Expo Workflow: managed

Reproducible demo or steps to reproduce from a blank project

I installed sentry based on the instructions from the guide in the expo docs, so there aren't any specifics worth mentioning with respect to Sentry. Some details worth noting regarding my setup:

erquhart commented 1 year ago

@MaxAst are you using expo router by chance? I started seeing this after customizing metro config to get builds working again after migrating to expo router. Ended up removing Sentry for now.

MaxAst commented 1 year ago

@erquhart nope, I'm not using expo router, just plain react navigation. My metro config looks like this, based on the working with monorepos docs :

// Learn more https://docs.expo.io/guides/customizing-metro
const { getDefaultConfig } = require("expo/metro-config");
const path = require("path");

// Find the workspace root, this can be replaced with `find-yarn-workspace-root`
const workspaceRoot = path.resolve(__dirname, "../..");
const projectRoot = __dirname;

const config = getDefaultConfig(projectRoot);

// 1. Watch all files within the monorepo
config.watchFolders = [workspaceRoot];
// 2. Let Metro know where to resolve packages, and in what order
config.resolver.nodeModulesPaths = [
  path.resolve(projectRoot, "node_modules"),
  path.resolve(workspaceRoot, "node_modules"),
];
// 3. Force Metro to resolve (sub)dependencies only from the `nodeModulesPaths`
config.resolver.disableHierarchicalLookup = true;

module.exports = config;
MaxAst commented 1 year ago

Fixed it by adding this to my monorepo's root package.json

  "workspaces": {
    "packages": [
      "apps/*",
      "packages/*"
    ],
    "nohoist": [
      "**/@sentry/react-native"
    ]
  },
beshur commented 1 year ago

any ideas how to fix it in non-monorepo environment? We use typescript and metro

MaxAst commented 1 year ago

@beshur errors like this are almost always related to sentry package version mismatches. Make sure that all sentry packages (e.g. @sentry/react-native) that sentry-expo depends on have the same version as yours

beshur commented 1 year ago

Thank you! Updating all the packages helped.

пн, 25 сент. 2023 г. в 18:25, Max @.***>:

@beshur https://github.com/beshur errors like this are almost always related to sentry package version mismatches. Make sure that all sentry packages (e.g. @sentry/react-native) that sentry-expo depends on have the same version as yours

— Reply to this email directly, view it on GitHub https://github.com/expo/sentry-expo/issues/332#issuecomment-1733947399, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEB6MPGHQ6W3QZ5ERWUC53X4GO5BANCNFSM6AAAAAAXZQFXZI . You are receiving this because you were mentioned.Message ID: @.***>

-- Alex Buznik @.***) 🇺🇦

http://buznik.net/