expo / sentry-expo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sentry in Expo Go environment breaks Promise.all + generator

mrlika opened this issue · comments

Summary

Sentry in Expo Go environment breaks Promise.all + generator. The code sample:

function* g(n: number) {
  let i = 0;
  while (i !== n) yield Promise.resolve(i++);
}

async function run() {
  console.log('RESULT', await Promise.all(g(7)));
}

run();

This code should output RESULT [0, 1, 2, 3, 4, 5, 6], but it outputs RESULT [] after the first and next hot reloads (i.e. code changes) if Senty is on in the Expo Go environment. It breaks all the following calls to Promise.all + generator.

Setting enableInExpoDevelopment: false in Sentry.init fixes the issue.

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

SDK Version (managed workflow only)

49

Environment

  expo-env-info 1.0.5 environment info:
    System:
      OS: Linux 6.5 Ubuntu 23.10 23.10 (Mantic Minotaur)
      Shell: 5.2.15 - /bin/bash
    Binaries:
      Node: 18.15.0 - ~/.nvm/versions/node/v18.15.0/bin/node
      npm: 9.5.0 - ~/.nvm/versions/node/v18.15.0/bin/npm
    npmPackages:
      expo: ^49.0.16 => 49.0.16 
      react: 18.2.0 => 18.2.0 
      react-dom: 18.2.0 => 18.2.0 
      react-native: 0.72.6 => 0.72.6 
    Expo Workflow: managed

Reproducible demo or steps to reproduce from a blank project

function* g(n: number) {
  let i = 0;
  while (i !== n) yield Promise.resolve(i++);
}

async function run() {
  console.log('RESULT', await Promise.all(g(7)));
}

run();

This also seems like it breaks in production environment. It is a big blocker to use Sentry with Expo at the moment.

+1. I am also seeing this in non-ExpoGo environments.

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.

Hi @mrlika,
sentry-expo was recently deprecated in favor of @sentry/react-native which supports Expo out of the box now.

I've tried the example code in the Expo sample app. And the output is as expected RESULT [0, 1, 2, 3, 4, 5, 6].

https://github.com/getsentry/sentry-react-native/blob/2b90b3d56d7fcbfe0f23befff3e14935ad21d6f3/samples/expo/app/(tabs)/index.tsx#L73

      <Button
        title="Capture message"
        onPress={() => {
          // Sentry.captureMessage('Captured message');
          function* g(n: number) {
            let i = 0;
            while (i !== n) yield Promise.resolve(i++);
          }

          async function run() {
            console.log('RESULT', await Promise.all(g(7)));
          }

          run();
        }}
      />

Let us know if @sentry/react-native fixes it for you and if not please open a new issue in https://github.com/getsentry/sentry-react-native

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.

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.