-
-
Notifications
You must be signed in to change notification settings - Fork 354
Fix how bundle IDs are getting defined for individual bundles #5342
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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'); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: could we reuse the |
||
| hash.update(bundleCode); | ||
| debugId = stringToUUID(hash.digest('hex')); | ||
| // eslint-disable-next-line no-console | ||
| console.log('info ' + `Bundle Debug ID (calculated): ${debugId}`); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. q: Wdyt of adding new tests for the fallback flow?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
|
||
There was a problem hiding this comment.
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