Skip to content

Conversation

@alwx
Copy link
Contributor

@alwx alwx commented Nov 6, 2025

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

Fixes #5250

Here is the root cause:

  • Lazy-loaded chunks are serialized separately with their own preModules array
  • The debug ID module is only added to the main bundle's preModules
  • When processing a lazy chunk, determineDebugIdFromBundleSource() can't find the debug ID → returns null
  • The code throws an error instead of handling this gracefully

The solution is to generate bundle IDs for individual code chunks.
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.

📝 Checklist

  • I added tests to verify changes
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • All tests passing
  • No breaking changes

@github-actions
Copy link
Contributor

github-actions bot commented Nov 6, 2025

Android (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 394.62 ms 435.14 ms 40.52 ms
Size 43.94 MiB 48.82 MiB 4.88 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
eb07ba3+dirty 419.49 ms 482.12 ms 62.63 ms
2adbd1e+dirty 366.13 ms 419.49 ms 53.36 ms
276d348+dirty 356.30 ms 405.27 ms 48.97 ms
95aaf8a+dirty 342.82 ms 393.75 ms 50.93 ms
f234eb4+dirty 313.23 ms 333.31 ms 20.08 ms
2b89ce9+dirty 372.22 ms 417.06 ms 44.84 ms
c1573b3+dirty 355.65 ms 448.82 ms 93.17 ms
818a608+dirty 350.29 ms 397.38 ms 47.09 ms
6fee48d+dirty 370.23 ms 427.86 ms 57.63 ms
b7aa1aa+dirty 281.02 ms 317.53 ms 36.51 ms

App size

Revision Plain With Sentry Diff
eb07ba3+dirty 7.15 MiB 8.42 MiB 1.27 MiB
2adbd1e+dirty 7.15 MiB 8.43 MiB 1.28 MiB
276d348+dirty 7.15 MiB 8.42 MiB 1.26 MiB
95aaf8a+dirty 7.15 MiB 8.41 MiB 1.26 MiB
f234eb4+dirty 7.15 MiB 8.46 MiB 1.30 MiB
2b89ce9+dirty 7.15 MiB 8.41 MiB 1.26 MiB
c1573b3+dirty 7.15 MiB 8.42 MiB 1.27 MiB
818a608+dirty 7.15 MiB 8.41 MiB 1.26 MiB
6fee48d+dirty 7.15 MiB 8.41 MiB 1.26 MiB
b7aa1aa+dirty 7.15 MiB 8.46 MiB 1.31 MiB

Previous results on branch: alwx/bugfix/serializer-fix

Startup times

Revision Plain With Sentry Diff
d432f3d+dirty 373.82 ms 387.57 ms 13.76 ms

App size

Revision Plain With Sentry Diff
d432f3d+dirty 43.94 MiB 48.82 MiB 4.88 MiB

@github-actions
Copy link
Contributor

github-actions bot commented Nov 6, 2025

Android (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 403.59 ms 422.00 ms 18.41 ms
Size 43.75 MiB 47.99 MiB 4.24 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
93137d1+dirty 400.15 ms 424.74 ms 24.59 ms
20d5eaa 377.62 ms 406.50 ms 28.88 ms
4167e15+dirty 344.77 ms 367.78 ms 23.01 ms
b7aa1aa+dirty 324.73 ms 327.76 ms 3.03 ms
1d62dde+dirty 409.00 ms 453.90 ms 44.90 ms
534ba8c 484.00 ms 499.93 ms 15.93 ms
6479fd5+dirty 412.95 ms 434.02 ms 21.07 ms
5ee3314+dirty 415.80 ms 426.14 ms 10.34 ms
1226664+dirty 347.45 ms 386.60 ms 39.15 ms
64cd15c 439.02 ms 427.63 ms -11.39 ms

App size

Revision Plain With Sentry Diff
93137d1+dirty 17.75 MiB 19.70 MiB 1.95 MiB
20d5eaa 17.75 MiB 20.15 MiB 2.41 MiB
4167e15+dirty 17.75 MiB 19.74 MiB 1.99 MiB
b7aa1aa+dirty 17.75 MiB 19.75 MiB 2.00 MiB
1d62dde+dirty 17.75 MiB 19.74 MiB 2.00 MiB
534ba8c 17.75 MiB 20.15 MiB 2.41 MiB
6479fd5+dirty 17.75 MiB 19.68 MiB 1.94 MiB
5ee3314+dirty 17.75 MiB 19.70 MiB 1.95 MiB
1226664+dirty 17.75 MiB 19.74 MiB 1.99 MiB
64cd15c 17.75 MiB 20.15 MiB 2.41 MiB

Previous results on branch: alwx/bugfix/serializer-fix

Startup times

Revision Plain With Sentry Diff
d432f3d+dirty 446.27 ms 438.84 ms -7.43 ms

App size

Revision Plain With Sentry Diff
d432f3d+dirty 43.75 MiB 47.99 MiB 4.24 MiB

@github-actions
Copy link
Contributor

github-actions bot commented Nov 6, 2025

iOS (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1220.71 ms 1213.25 ms -7.46 ms
Size 3.41 MiB 4.58 MiB 1.17 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
7be1f99+dirty 1222.43 ms 1217.15 ms -5.28 ms
46da307+dirty 1213.45 ms 1207.96 ms -5.49 ms
534ba8c+dirty 1225.00 ms 1237.43 ms 12.43 ms
a0b15d6+dirty 1213.79 ms 1210.45 ms -3.34 ms
59f3a84+dirty 1205.09 ms 1213.31 ms 8.23 ms
20daa0a+dirty 1227.71 ms 1233.72 ms 6.01 ms
8ece263+dirty 1206.90 ms 1211.45 ms 4.55 ms
df83aad+dirty 1202.06 ms 1203.83 ms 1.77 ms
c94a927+dirty 1211.33 ms 1223.31 ms 11.97 ms
46bd012+dirty 1231.78 ms 1212.30 ms -19.47 ms

App size

Revision Plain With Sentry Diff
7be1f99+dirty 3.19 MiB 4.38 MiB 1.19 MiB
46da307+dirty 3.19 MiB 4.44 MiB 1.25 MiB
534ba8c+dirty 3.19 MiB 4.38 MiB 1.19 MiB
a0b15d6+dirty 3.19 MiB 4.38 MiB 1.19 MiB
59f3a84+dirty 3.19 MiB 4.56 MiB 1.37 MiB
20daa0a+dirty 3.19 MiB 4.38 MiB 1.19 MiB
8ece263+dirty 3.19 MiB 4.48 MiB 1.29 MiB
df83aad+dirty 3.41 MiB 4.57 MiB 1.16 MiB
c94a927+dirty 3.19 MiB 4.56 MiB 1.37 MiB
46bd012+dirty 3.19 MiB 4.38 MiB 1.19 MiB

Previous results on branch: alwx/bugfix/serializer-fix

Startup times

Revision Plain With Sentry Diff
d432f3d+dirty 1193.77 ms 1194.71 ms 0.95 ms

App size

Revision Plain With Sentry Diff
d432f3d+dirty 3.41 MiB 4.58 MiB 1.17 MiB

@github-actions
Copy link
Contributor

github-actions bot commented Nov 6, 2025

iOS (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1224.29 ms 1223.96 ms -0.34 ms
Size 3.41 MiB 4.58 MiB 1.17 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
7be1f99+dirty 1226.69 ms 1217.76 ms -8.93 ms
46da307+dirty 1217.08 ms 1224.16 ms 7.08 ms
534ba8c+dirty 1230.22 ms 1231.18 ms 0.96 ms
a0b15d6+dirty 1220.18 ms 1223.18 ms 3.00 ms
59f3a84+dirty 1232.56 ms 1238.12 ms 5.56 ms
20daa0a+dirty 1233.12 ms 1233.35 ms 0.22 ms
8ece263+dirty 1217.29 ms 1213.35 ms -3.94 ms
df83aad+dirty 1187.20 ms 1190.55 ms 3.36 ms
c94a927+dirty 1227.14 ms 1239.64 ms 12.50 ms
46bd012+dirty 1220.49 ms 1226.89 ms 6.40 ms

App size

Revision Plain With Sentry Diff
7be1f99+dirty 2.63 MiB 3.81 MiB 1.18 MiB
46da307+dirty 2.63 MiB 3.87 MiB 1.24 MiB
534ba8c+dirty 2.63 MiB 3.81 MiB 1.18 MiB
a0b15d6+dirty 2.63 MiB 3.81 MiB 1.18 MiB
59f3a84+dirty 2.63 MiB 3.99 MiB 1.36 MiB
20daa0a+dirty 2.63 MiB 3.81 MiB 1.18 MiB
8ece263+dirty 2.63 MiB 3.91 MiB 1.28 MiB
df83aad+dirty 3.41 MiB 4.57 MiB 1.16 MiB
c94a927+dirty 2.63 MiB 3.99 MiB 1.36 MiB
46bd012+dirty 2.63 MiB 3.81 MiB 1.18 MiB

Previous results on branch: alwx/bugfix/serializer-fix

Startup times

Revision Plain With Sentry Diff
d432f3d+dirty 1219.17 ms 1209.83 ms -9.34 ms

App size

Revision Plain With Sentry Diff
d432f3d+dirty 3.41 MiB 4.58 MiB 1.17 MiB

@alwx alwx marked this pull request as ready for review November 7, 2025 08:47
@alwx alwx self-assigned this Nov 7, 2025
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.

// 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?

Copy link
Contributor

@antonis antonis left a comment

Choose a reason for hiding this comment

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

Awesome work identifying and fixing this @alwx 🎸
The fallback approach looks solid to me. Added a couple of questions but overall LGTM.

### 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

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[react native 0.82.0] Debug ID was not found in the bundle. Call options.sentryBundleCallback if you are using a custom serializer.

4 participants