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

Does not work with Expo 52: Uncaught Error "undefined is not a function" #4341

Open
ian opened this issue Dec 4, 2024 · 7 comments
Open

Comments

@ian
Copy link

ian commented Dec 4, 2024

What React Native libraries do you use?

Expo Router, Expo (mobile only)

Are you using sentry.io or on-premise?

sentry.io (SaS)

@sentry/react-native SDK Version

6.3.0

How does your development environment look like?

(NOBRIDGE) ERROR TypeError: undefined is not a function [Component Stack]

Image

Sentry.init()

Sentry.init({
dsn: "...",
})

Steps to Reproduce

Use "expo": "52.0.14"

Then set your app/_layout.tsx like this:

import { Stack } from "expo-router"
import * as SplashScreen from "expo-splash-screen"
import { useEffect } from "react"
import * as Sentry from "@sentry/react-native"

Sentry.init({
  dsn: "...",
})

// Prevent the splash screen from auto-hiding before asset loading is complete.
SplashScreen.preventAutoHideAsync()

function RootLayout() {
  useEffect(() => {
    SplashScreen.hideAsync()
  }, [])

  return (
    <Stack>
      <Stack.Screen name="+not-found" />
    </Stack>
  )
}

export default Sentry.wrap(RootLayout)

And app/index.tsx

import { View, Text } from "react-native"

export default function HomeScreen() {
  return (
    <View>
      <Text>Hello, world.</Text>
    </View>
  )
}

metro.config.js

const path = require("path")
const { getSentryExpoConfig } = require("@sentry/react-native/metro")
const { FileStore } = require("metro-cache")

// Find the project and workspace directories
const projectRoot = __dirname

// This can be replaced with `find-pnpm-workspace-root`
const workspaceRoot = path.resolve(projectRoot, "../..")
const config = getSentryExpoConfig(__dirname)

console.log(config)

config.transformer.getTransformOptions = async () => ({
  transform: {
    experimentalImportSupport: true,
    inlineRequires: false,
  },
})

config.resolver.extraNodeModules = {
  stream: require.resolve("readable-stream"),
}

config.resolver.nodeModulesPaths = [
  path.resolve(projectRoot, "node_modules"),
  path.resolve(workspaceRoot, "node_modules"),
]

config.resolver.disableHierarchicalLookup = true

config.cacheStores = [
  new FileStore({
    root: path.join(projectRoot, "node_modules", ".cache", "metro"),
  }),
]

module.exports = config

Expected Result

No error, app loads

Actual Result

App crashes immediately.

@krystofwoldrich
Copy link
Member

Hi @ian,
thank you for the message,

have Sentry RN package work for you with the previous Expo version?

@ian
Copy link
Author

ian commented Dec 4, 2024 via email

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Dec 4, 2024
@ian
Copy link
Author

ian commented Dec 4, 2024

@krystofwoldrich here's a minimum reproducible example: https://github.com/ian/sentry-repro

Used https://docs.expo.dev/guides/using-sentry/ as an installation guide, and getting same issue. Let me know if you need more info.

Image

@krystofwoldrich
Copy link
Member

Thank you.

@gunnartorfis
Copy link

Additional context, this does not happen in 6.1.0, but does in 6.3.0.

@ian
Copy link
Author

ian commented Dec 11, 2024

Confirmed what @gunnartorfis suggested, downgrading to 6.1.0 fixes it.

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Dec 11, 2024
@kahest
Copy link
Member

kahest commented Dec 13, 2024

thanks for confirming 👍 this should help narrow the problem down

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Status: Needs Investigation
Development

No branches or pull requests

4 participants