sentry-react-native icon indicating copy to clipboard operation
sentry-react-native copied to clipboard

TypeError: options.shouldAddToIgnoreList is not a function

Open muratoner opened this issue 1 year ago • 26 comments

OS:

  • [ ] Windows
  • [X] MacOS
  • [ ] Linux

Platform:

  • [X] iOS
  • [X] Android

SDK:

  • [X] @sentry/react-native (>= 1.0.0)
  • [ ] react-native-sentry (<= 0.43.2)

SDK version: 5.19.0

react-native version: 0.71.13

Are you using Expo?

  • [ ] Yes
  • [X] No

Are you using sentry.io or on-premise?

  • [X] sentry.io (SaaS)
  • [ ] on-premise

If you are using sentry.io, please post a link to your issue so we can take a look:

[Link to issue]

Configuration:

(@sentry/react-native)

Sentry.init({
  dsn: 'https://[email protected]/...'
  // other options
});

I have the following issue:

[Description]

Steps to reproduce:

  • Start to archive process in xcode
  • Throwed exception when bundling metro step

Actual result:

error options.shouldAddToIgnoreList is not a function. TypeError: options.shouldAddToIgnoreList is not a function at getSourceMapInfo (/Users/muratoner/Desktop/Projects.SabanciDx/hrweb/node_modules/metro/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.js:18:24) at processNextModule (/Users/muratoner/Desktop/Projects.SabanciDx/hrweb/node_modules/metro/src/DeltaBundler/Serializers/sourceMapGenerator.js:30:18) at workLoop (/Users/muratoner/Desktop/Projects.SabanciDx/hrweb/node_modules/metro/src/DeltaBundler/Serializers/sourceMapGenerator.js:40:22) at getSourceMapInfosImpl (/Users/muratoner/Desktop/Projects.SabanciDx/hrweb/node_modules/metro/src/DeltaBundler/Serializers/sourceMapGenerator.js:60:3) at sourceMapGenerator (/Users/muratoner/Desktop/Projects.SabanciDx/hrweb/node_modules/metro/src/DeltaBundler/Serializers/sourceMapGenerator.js:64:3) at sourceMapString (/Users/muratoner/Desktop/Projects.SabanciDx/hrweb/node_modules/metro/src/DeltaBundler/Serializers/sourceMapString.js:16:10) at /Users/muratoner/Desktop/Projects.SabanciDx/hrweb/node_modules/@sentry/react-native/dist/js/tools/vendor/metro/utils.js:42:21 at Object. (/Users/muratoner/Desktop/Projects.SabanciDx/hrweb/node_modules/@sentry/react-native/dist/js/tools/sentryMetroSerializer.js:53:38) at Generator.next () at /Users/muratoner/Desktop/Projects.SabanciDx/hrweb/node_modules/tslib/tslib.js:169:75

Expected result:

Take an archive in xcode

muratoner avatar Feb 22 '24 10:02 muratoner

same error here trying to generate source maps: error options.shouldAddToIgnoreList is not a function. TypeError: options.shouldAddToIgnoreList is not a function at getSourceMapInfo (/Users/[email protected]/tr_spinplus/node_modules/metro/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.js:7:24) at processNextModule (/Users/[email protected]/tr_spinplus/node_modules/metro/src/DeltaBundler/Serializers/sourceMapGenerator.js:19:18) at workLoop (/Users/[email protected]/tr_spinplus/node_modules/metro/src/DeltaBundler/Serializers/sourceMapGenerator.js:29:22) at getSourceMapInfosImpl (/Users/[email protected]/tr_spinplus/node_modules/metro/src/DeltaBundler/Serializers/sourceMapGenerator.js:44:3) at sourceMapGenerator (/Users/[email protected]/tr_spinplus/node_modules/metro/src/DeltaBundler/Serializers/sourceMapGenerator.js:48:3) at sourceMapString (/Users/[email protected]/tr_spinplus/node_modules/metro/src/DeltaBundler/Serializers/sourceMapString.js:5:10) at /Users/[email protected]/tr_spinplus/node_modules/@sentry/react-native/dist/js/tools/vendor/metro/utils.js:42:21 at Object. (/Users/[email protected]/tr_spinplus/node_modules/@sentry/react-native/dist/js/tools/sentryMetroSerializer.js:36:38) at Generator.next () at /Users/[email protected]/tr_spinplus/node_modules/tslib/tslib.js:169:75 info Run CLI with --verbose flag for more details. Error! Failed to open file: index.android.bundle mv: rename index.android.bundle.hbc to index.android.bundle: No such file or directory Copy debugId from packager source map to Hermes source map... Packager source map does not have debugId.

Found 1 file Analyzing 1 sources Analyzing completed in 0.021s Rewriting sources Rewriting completed in 0.139s Adding source map references Bundling completed in 0.233s Bundled 1 file for upload Bundle ID: 92c0c796-2abc-55da-b721-c3432e95c6e5 Optimizing completed in 0.003s Uploading completed in 0.428s Uploaded files to Sentry Processing completed in 0.32s File upload complete (processing pending on server) Organization: femsa-digital Project: spin-premia Release: [email protected]+1 Dist: 1 Upload type: artifact bundle

Source Map Upload Report Source Maps ~/index.android.bundle.map

gerdigitalfemsa avatar Feb 23 '24 04:02 gerdigitalfemsa

Hi @muratoner and @gerdigitalfemsa, thank you for the messages,

this is usually a result of the hoisted metro version and the metro shipped with RN.

Can you share what version of Metro is ./node_modules/metro?

Does the issue resolve when you install [email protected]?

krystofwoldrich avatar Feb 23 '24 17:02 krystofwoldrich

i am having a same error

when i try to build ios bundler file i get :

Recrawled this watch 75 times, most recently because: MustScanSubDirs UserDroppedTo resolve, please review the information on https://facebook.github.io/watchman/docs/troubleshooting.html#recrawl To clear this warning, run:watchman watch-del '/Users/levancho/dev/kwickie/kwikorder-ui-gary' ; watchman watch-project '/Users/levancho/dev/kwickie/kwikorder-ui-gary'`

error options.shouldAddToIgnoreList is not a function. TypeError: options.shouldAddToIgnoreList is not a function at getSourceMapInfo (/Users/levancho/dev/kwickie/kwikorder-ui-gary/node_modules/metro/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.js:18:24) at processNextModule (/Users/levancho/dev/kwickie/kwikorder-ui-gary/node_modules/metro/src/DeltaBundler/Serializers/sourceMapGenerator.js:30:18) at workLoop (/Users/levancho/dev/kwickie/kwikorder-ui-gary/node_modules/metro/src/DeltaBundler/Serializers/sourceMapGenerator.js:40:22) at getSourceMapInfosImpl (/Users/levancho/dev/kwickie/kwikorder-ui-gary/node_modules/metro/src/DeltaBundler/Serializers/sourceMapGenerator.js:60:3) at sourceMapGenerator (/Users/levancho/dev/kwickie/kwikorder-ui-gary/node_modules/metro/src/DeltaBundler/Serializers/sourceMapGenerator.js:64:3) at sourceMapString (/Users/levancho/dev/kwickie/kwikorder-ui-gary/node_modules/metro/src/DeltaBundler/Serializers/sourceMapString.js:16:10) at /Users/levancho/dev/kwickie/kwikorder-ui-gary/node_modules/@sentry/react-native/dist/js/tools/vendor/metro/utils.js:42:21 at Object. (/Users/levancho/dev/kwickie/kwikorder-ui-gary/node_modules/@sentry/react-native/dist/js/tools/sentryMetroSerializer.js:53:38) at Generator.next () at /Users/levancho/dev/kwickie/kwikorder-ui-gary/node_modules/tslib/tslib.js:169:75`

levancho avatar Feb 25 '24 12:02 levancho

I tried with metro versions all the way up to 0.76 (inclusive) same error.

levancho avatar Feb 25 '24 12:02 levancho

is there an update on this? we are blocked..

levancho avatar Feb 26 '24 17:02 levancho

Hi @muratoner and @gerdigitalfemsa, thank you for the messages,

this is usually a result of the hoisted metro version and the metro shipped with RN.

Can you share what version of Metro is ./node_modules/metro?

Does the issue resolve when you install [email protected]?

My ./node_modules/metro version is 0.80.5

muratoner avatar Feb 26 '24 23:02 muratoner

testing the build on Xcode cloud.. will report the result here ..

levancho avatar Feb 26 '24 23:02 levancho

so, problem I think is that many users do not explicitly declare metro dependencies, since its get pulled down transitively anyways.. so with react native 0.71.14 I am getting metro version that was breaking this.. so explicitly adding 0.73.10 fixed the problem. but only that version all others versions did not work for me, including 0.86.

levancho avatar Feb 27 '24 00:02 levancho

@krystofwoldrich i got "version": "0.73.10", image

gerdigitalfemsa avatar Feb 27 '24 00:02 gerdigitalfemsa

Thank you all for your findings, we're investigating

kahest avatar Feb 27 '24 17:02 kahest

I am also getting this error when updating sentry with the wizard. Is it possible still to add sentry without the metro.config.js changes?

sisoalbert avatar Feb 28 '24 14:02 sisoalbert

Hi @sisoalbert, you can use Sentry without modifying the metro.config.js, but you will have to ensure release and dist are correctly set for source maps mapping. Debug IDs, which are used by default, won't be available, because they are generated in the Metro Sentry serializer.

https://docs.sentry.io/platforms/react-native/sourcemaps/troubleshooting/optional-release-and-distribution/

krystofwoldrich avatar Feb 28 '24 16:02 krystofwoldrich

@muratoner Have installing [email protected] resolved the issue?

krystofwoldrich avatar Feb 29 '24 12:02 krystofwoldrich

Current workaround to fix the issue

  1. Check what version of metro is used by your version of react-native

    Example: [email protected] uses metro@^0.80.3 (package.json)

  2. Install that metro version as a dependency in your project.

    Example: npm install metro@^0.80.3

krystofwoldrich avatar Feb 29 '24 12:02 krystofwoldrich

The solution is to not rely on hoisted metro dependency and resolve react-native -> @react-native-community/cli-plugin-metro or @react-native/community-cli-plugin -> metro, which is the metro package used by the React Native CLI.

      const reactNativeDir = require.resolve('react-native/package.json');
      const cliDir = require.resolve('@react-native/community-cli-plugin/package.json', { paths: [reactNativeDir] });
      const metroDir = require.resolve('metro/package.json', { paths: [cliDir] });
      console.log('info ' + `reactNativeDir: ${reactNativeDir}`);
      console.log('info ' + `cliDir: ${cliDir}`);
      console.log('info ' + `metroDir: ${metroDir}`);

krystofwoldrich avatar Feb 29 '24 12:02 krystofwoldrich

Add a troubleshooting note to https://docs.sentry.io/platforms/react-native/manual-setup/metro/

krystofwoldrich avatar Mar 08 '24 13:03 krystofwoldrich

I had a similar issue in a monorepo setup

Fixed by

  1. I had dependency conflicts, had metro-config, metro-react-native-babel-preset and @react-native/metro-config present in my package.json
  • removed old ones (metro-config, metro-react-native-babel-preset)
  • kept official one for latest RN 0.73.6 which is "@react-native/metro-config": "0.73.5"
  1. Ensure metro dependencies are not hoisted and available at package node_modules, not root mono repo node_modules at root package.json add to achieve that

"nohoist": [ "**/@react-native/**", ]

NabeelZanabeet avatar Mar 20 '24 23:03 NabeelZanabeet

@NabeelZanabeet Thank you for sharing the steps.

krystofwoldrich avatar Mar 21 '24 19:03 krystofwoldrich

I get this exact same error on App-center, although i am able to build locally from my IDE and with xcode. This is what my metro-file looks like:

const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');
const {createSentryMetroSerializer} = require('@sentry/react-native/dist/js/tools/sentryMetroSerializer');

module.exports = (async () => {
  // default Metro configuration
  const defaultConfig = await getDefaultConfig(__dirname);
  const {
    resolver: {sourceExts, assetExts},
  } = defaultConfig;

  // custom configuration for Sentry
  const sentryConfig = {
    serializer: {
      customSerializer: createSentryMetroSerializer(),
    },
  };

  // existing custom configuration
  const customConfig = {
    transformer: {
      babelTransformerPath: require.resolve('react-native-svg-transformer'),
    },
    resolver: {
      assetExts: assetExts.filter(ext => ext !== 'svg'),
      sourceExts: [...sourceExts, 'svg'],
    },
  };

  // Merge Sentry configuration with all custom configuration
  const config = mergeConfig(defaultConfig, sentryConfig, customConfig);

  return config;
})();

sleekLancelot avatar May 24 '24 06:05 sleekLancelot

Hi @sleekLancelot, have you tried this workaround?

  • https://github.com/getsentry/sentry-react-native/issues/3622#issuecomment-1971056220

Likely the local node_modules modules do not match the server, you can try to remove the local node_modules and install them again, the should help with reproducing the issue.

krystofwoldrich avatar May 24 '24 08:05 krystofwoldrich

Hi @sleekLancelot, have you tried this workaround?

Likely the local node_modules modules do not match the server, you can try to remove the local node_modules and install them again, the should help with reproducing the issue.

Hi Krystof, not sure why this didn't work hours ago, but i tried it again and it worked! i have "react-native": "0.71.4" installed. Which uses "metro-runtime": "0.73.8" so i did yarn add [email protected] And now the build was succesful! Thanks alot for your help.

sleekLancelot avatar May 24 '24 22:05 sleekLancelot

@sleekLancelot Awesome, no worries, I'm happy to hear it worked out.

krystofwoldrich avatar May 27 '24 09:05 krystofwoldrich

I've tested that the following logic resolves the correct metro non hoisted metro package.

const reactNativeDir = require.resolve('react-native/package.json');
const cliDir = require.resolve('@react-native/community-cli-plugin/package.json', { paths: [reactNativeDir] });
const metroDir = require.resolve('metro/package.json', { paths: [cliDir] });
console.log('info ' + `reactNativeDir: ${reactNativeDir}`);
console.log('info ' + `cliDir: ${cliDir}`);
console.log('info ' + `metroDir: ${metroDir}`);

krystofwoldrich avatar Jun 13 '24 11:06 krystofwoldrich