Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
### Fixes

- Android SDK not being disabled when `options.enabled` is set to `false` ([#5334](https://github.com/getsentry/sentry-react-native/pull/5334))
- Fixes how bundle IDs are getting defined for individual bundles ([#5342](https://github.com/getsentry/sentry-react-native/pull/5342))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could add a reference to 0.83.2+ here


### Dependencies

Expand Down
16 changes: 12 additions & 4 deletions packages/core/src/js/tools/sentryMetroSerializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,19 @@ export const createSentryMetroSerializer = (customSerializer?: MetroSerializer):
const { code: bundleCode, map: bundleMapString } = await extractSerializerResult(serializerResult);

// Add debug id comment to the bundle
const debugId = determineDebugIdFromBundleSource(bundleCode);
let debugId = determineDebugIdFromBundleSource(bundleCode);
if (!debugId) {
throw new Error(
'Debug ID was not found in the bundle. Call `options.sentryBundleCallback` if you are using a custom serializer.',
);
// For lazy-loaded chunks or bundles without the debug ID module,
// calculate the debug ID from the bundle content.
// This ensures Metro 0.83.2+ code-split bundles get debug IDs.
// That needs to be done because when Metro 0.83.2 stopped importing `BabelSourceMapSegment`
// from `@babel/generator` and defined it locally, it subtly changed the source map output format.
// https://github.com/facebook/metro/blob/main/packages/metro-source-map/src/source-map.js#L47
const hash = crypto.createHash('md5');
Copy link
Contributor

@antonis antonis Nov 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: could we reuse the calculateDebugId function below?

hash.update(bundleCode);
debugId = stringToUUID(hash.digest('hex'));
// eslint-disable-next-line no-console
console.log('info ' + `Bundle Debug ID (calculated): ${debugId}`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

q: Wdyt of adding new tests for the fallback flow?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed that we should at least add one test.

}
// Only print debug id for command line builds => not hot reload from dev server
// eslint-disable-next-line no-console
Expand Down
Loading