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

sourceMapString is not a function [v5.28.0] #4005

Closed
6 of 11 tasks
devphilipcesar opened this issue Aug 8, 2024 · 12 comments
Closed
6 of 11 tasks

sourceMapString is not a function [v5.28.0] #4005

devphilipcesar opened this issue Aug 8, 2024 · 12 comments

Comments

@devphilipcesar
Copy link

devphilipcesar commented Aug 8, 2024

OS:

  • Windows
  • MacOS
  • Linux

Platform:

  • iOS
  • Android

SDK:

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

SDK version: 5.26.0

react-native version: 0.73.9

Are you using Expo?

  • Yes
  • No

Are you using sentry.io or on-premise?

  • 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
});

or

(react-native-sentry)

Sentry.config(
  'https://[email protected]/...'
  // other options
 ).install();

I have the following issue:

[Description]

Steps to reproduce:

  • Step 1
  • Step 2

Actual result:

Image

ANDROID

Image

iOS

Image

Expected result:

[Expected result]

@github-project-automation github-project-automation bot moved this to Needs Discussion in Mobile & Cross Platform SDK Aug 8, 2024
@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Aug 8, 2024
@devphilipcesar devphilipcesar changed the title Expo EAS Android Build error: TypeError: sourceMapString is not a function Expo EAS Android and iOS Build error: TypeError: sourceMapString is not a function Aug 8, 2024
@vineyardbovines
Copy link

Seeing the same issue.

Expo SDK 51
@sentry/react-native v5.22.0

Image

@devphilipcesar
Copy link
Author

[UPDATE]

I was able to fix issue by removing the createSentryMetroSerializer and the whole serializer

Old file:

Image

Updated file:

Image

@matthijsFoF
Copy link

matthijsFoF commented Aug 9, 2024

We're having the same issue on a bare react-native project, is removing this createSentryMetroSerializer really the way to go here? This means source maps won't work properly anymore with sentry, see:
https://docs.sentry.io/platforms/react-native/manual-setup/metro/

Sentry's React Native SDK package ships with a Sentry Metro Serializer which allows you to automatically generate Debug IDs for your applications' bundles. This is crucial for making source maps work properly with Sentry. This page will guide you through the process of setting up the Metro Plugin for your application.

This was also generated by the sentry wizard.

TypeError: sourceMapString is not a function
error sourceMapString is not a function.

Our metro.config file looks like this:

const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');

const {
 withSentryConfig
} = require("@sentry/react-native/metro");

/**
 * Metro configuration
 * https://reactnative.dev/docs/metro
 *
 * @type {import('metro-config').MetroConfig}
 */
const config = {};

module.exports = withSentryConfig(mergeConfig(getDefaultConfig(__dirname), config));

@devphilipcesar
Copy link
Author

Hi @matthijsFoF basically at that time I bump the sentry react native version to 5.27.0 and removed that createSentryMetroSerializer... I tested using the Sentry test error and I was able to track the error on Sentry Dashboard with no issues on sourcemaps.

UPDATE:
update to 5.28.0 will resolve the issue.

@vineyardbovines
Copy link

We aren't using createSentryMetroSerializer in our config, so I'm not sure that resolves the issue fully. We are also on 5.28.0 and still seeing the error, @devphilipcesar do you mind reopening this issue?

Logs:

Image

Metro config file:

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

module.exports = withTurborepoManagedCache(
  withMonorepoPaths(getSentryExpoConfig(__dirname))
);

function withMonorepoPaths(config) {
  const projectRoot = __dirname;
  const workspaceRoot = path.resolve(projectRoot, "../..");

  config.watchFolders = [workspaceRoot];

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

  return config;
}

function withTurborepoManagedCache(config) {
  config.cacheStores = [
    new FileStore({ root: path.join(__dirname, "node_modules/.cache/metro") }),
  ];
  return config;
}

@devphilipcesar devphilipcesar reopened this Aug 9, 2024
@devphilipcesar devphilipcesar changed the title Expo EAS Android and iOS Build error: TypeError: sourceMapString is not a function Expo EAS Android and iOS Build error: TypeError: sourceMapString is not a function [v5.28.0] Aug 9, 2024
@matthijsFoF
Copy link

Hi @devphilipcesar, fixed for us now, thanks for the quick response!

@atitpatel
Copy link

atitpatel commented Aug 11, 2024

Our appcenter builds have started failing due to the same error.
React native: 0.74.1
Different sentry packages:

"@sentry/cli": "2.32.2",
"@sentry/integrations": "7.101.1",
"@sentry/react-native": "5.20.0",

These builds were working fine till Friday last week and then started failing without any library change from our end. Any help is appreciated here. Thanks!

P.S.: I tried upgrading @sentry/react-native to 5.28.0, but kept getting build errors around Sentry/HybridSDK and various attempts to update pods didn't help it.

@krystofwoldrich krystofwoldrich moved this from Done to Needs Validation in Mobile & Cross Platform SDK Aug 12, 2024
@krystofwoldrich
Copy link
Member

Hello everyone,
The issue was caused by the latest Metro update changing the sourceMapString function export.

It was fixed by this PR.

Please upgrade to https://github.com/getsentry/sentry-react-native/releases/tag/5.28.0

@krystofwoldrich
Copy link
Member

@gretzky I see you mentioned you are on https://github.com/getsentry/sentry-react-native/releases/tag/5.28.0 but still seeing the error, could you check that your that the build is not using older version from cache?

@krystofwoldrich
Copy link
Member

I tried upgrading @sentry/react-native to 5.28.0, but kept getting build errors around Sentry/HybridSDK and various attempts to update pods didn't help it.

@atitpatel Could you share what errors are you getting?

@krystofwoldrich krystofwoldrich changed the title Expo EAS Android and iOS Build error: TypeError: sourceMapString is not a function [v5.28.0] sourceMapString is not a function [v5.28.0] Aug 13, 2024
@krystofwoldrich krystofwoldrich moved this from Needs Validation to Needs Investigation in Mobile & Cross Platform SDK Aug 13, 2024
@krystofwoldrich krystofwoldrich moved this from Needs Investigation to Needs More Information in Mobile & Cross Platform SDK Aug 13, 2024
@github-project-automation github-project-automation bot moved this from Needs More Information to Done in Mobile & Cross Platform SDK Aug 16, 2024
@sieu-db
Copy link

sieu-db commented Aug 21, 2024

Hi, we are also on 5.28.0 and still seeing the error, @devphilipcesar @krystofwoldrich do you mind reopening this issue ?

Expo 50
Sentry 5.28.0

The same code build without issues ~2 weeks ago, but right now facing error below

error: (0 , sourceMapString_1.default) is not a function
TypeError: (0 , sourceMapString_1.default) is not a function
TypeError: (0 , sourceMapString_1.default) is not a function
    at /Users/builder/clone/node_modules/expo/node_modules/@expo/metro-config/build/serializer/withExpoSerializers.js:98:55
    at /Users/builder/clone/node_modules/expo/node_modules/@expo/metro-config/build/serializer/withExpoSerializers.js:156:20
    at Object.customSerializer (/Users/builder/clone/node_modules/expo/node_modules/@expo/metro-config/build/serializer/withExpoSerializers.js:182:16)
    at Server.build (/Users/builder/clone/node_modules/metro/src/Server.js:156:52)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async exportEmbedBundleAsync (/Users/builder/clone/node_modules/@expo/cli/build/src/export/embed/exportEmbedAsync.js:134:16)
    at async exportEmbedBundleAndAssetsAsync (/Users/builder/clone/node_modules/@expo/cli/build/src/export/embed/exportEmbedAsync.js:122:24)
    at async exportEmbedAsync (/Users/builder/clone/node_modules/@expo/cli/build/src/export/embed/exportEmbedAsync.js:62:34)
+ '[' -z '' ']'
++ /usr/local/bin/node --print 'require('\''path'\'').dirname(require.resolve('\''@sentry/react-native/package.json'\''))'

@Njinou
Copy link

Njinou commented Nov 3, 2024

@sieu-db p lease any update on that issue ?

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

No branches or pull requests

7 participants