Skip to content

fix(core): Lazy-load Metro internal modules to prevent Expo 55 import errors#5958

Merged
lucas-zimerman merged 5 commits intomainfrom
lz/5957
Apr 7, 2026
Merged

fix(core): Lazy-load Metro internal modules to prevent Expo 55 import errors#5958
lucas-zimerman merged 5 commits intomainfrom
lz/5957

Conversation

@lucas-zimerman
Copy link
Copy Markdown
Collaborator

@lucas-zimerman lucas-zimerman commented Apr 6, 2026

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

Defer requiring Metro internals (baseJSBundle, sourceMapString, bundleToString) until they're actually needed during serialization, rather than at module import time. This prevents "Cannot find module 'metro/src/DeltaBundler/Serializers/baseJSBundle'" errors when Metro is only a transitive dependency through Expo.

The fix moves Metro module requires from module-level to inside createDefaultMetroSerializer(), ensuring the config can be imported successfully even when Metro internals aren't immediately available.

💡 Motivation and Context

Fixes #5957

💚 How did you test it?

Expo sample app

📝 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

🔮 Next steps

lucas-zimerman and others added 2 commits April 6, 2026 23:35
… errors

Defer requiring Metro internals (baseJSBundle, sourceMapString, bundleToString)
until they're actually needed during serialization, rather than at module import
time. This prevents "Cannot find module 'metro/src/DeltaBundler/Serializers/baseJSBundle'"
errors when Metro is only a transitive dependency through Expo.

The fix moves Metro module requires from module-level to inside
createDefaultMetroSerializer(), ensuring the config can be imported
successfully even when Metro internals aren't immediately available.

Fixes #5957

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 6, 2026

Semver Impact of This PR

None (no version bump detected)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


  • fix(core): Lazy-load Metro internal modules to prevent Expo 55 import errors by lucas-zimerman in #5958
  • chore(deps): update Cocoa SDK to v9.9.0 by github-actions in #5956
  • chore(deps): update Maestro to v2.4.0 by github-actions in #5955
  • Feat: Fallback to stacktrace parsing by lucas-zimerman in #5946
  • fix(ci): Bump Node to 22 in size-analysis and testflight workflows by antonis in #5954
  • feat(playground): Open Sentry in desktop browser from Expo apps by antonis in #5947
  • chore(core): Bump sample app to React Native 0.84.1 by antonis in #5941
  • Size analysis for React Native SDK by alwx in #5949
  • chore(deps): bump lodash from 4.17.23 to 4.18.1 by dependabot in #5953
  • chore(deps): bump yauzl to ^3.2.1 by antonis in #5950
  • chore(deps): bump brace-expansion to ^2.0.3 by antonis in #5951
  • chore(deps): bump @xmldom/xmldom to fix XML injection by antonis in #5952

🤖 This preview updates automatically when you update the PR.

@sentry
Copy link
Copy Markdown

sentry bot commented Apr 6, 2026

Sentry Build Distribution

App Name App ID Version Configuration Install Page
Sentry RN io.sentry.reactnative.sample 8.7.0 (82) Release Install Build

@antonis antonis added the ready-to-merge Triggers the full CI test suite label Apr 7, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

Android (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 570.73 ms 608.96 ms 38.23 ms
Size 43.75 MiB 48.08 MiB 4.33 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
4953e94+dirty 442.02 ms 456.52 ms 14.50 ms
3817909+dirty 406.67 ms 416.58 ms 9.91 ms
df5d108+dirty 527.06 ms 603.58 ms 76.52 ms
a50b33d+dirty 500.81 ms 532.11 ms 31.30 ms

App size

Revision Plain With Sentry Diff
4953e94+dirty 43.75 MiB 48.08 MiB 4.33 MiB
3817909+dirty 43.75 MiB 48.08 MiB 4.33 MiB
df5d108+dirty 43.75 MiB 48.08 MiB 4.33 MiB
a50b33d+dirty 43.75 MiB 48.08 MiB 4.33 MiB

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

iOS (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1203.79 ms 1207.53 ms 3.74 ms
Size 3.38 MiB 4.73 MiB 1.35 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
4953e94+dirty 1212.06 ms 1214.83 ms 2.77 ms
df5d108+dirty 1225.90 ms 1220.14 ms -5.76 ms
a50b33d+dirty 1197.74 ms 1197.17 ms -0.57 ms
3817909+dirty 1183.90 ms 1187.50 ms 3.60 ms

App size

Revision Plain With Sentry Diff
4953e94+dirty 3.38 MiB 4.73 MiB 1.35 MiB
df5d108+dirty 3.38 MiB 4.73 MiB 1.35 MiB
a50b33d+dirty 3.38 MiB 4.73 MiB 1.35 MiB
3817909+dirty 3.38 MiB 4.73 MiB 1.35 MiB

Copy link
Copy Markdown
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.

LGTM 🚀
Great fix Lucas. Just left a comment on a stray comment :)

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

iOS (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1197.10 ms 1192.46 ms -4.64 ms
Size 3.38 MiB 4.73 MiB 1.35 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
4953e94+dirty 1217.41 ms 1223.53 ms 6.12 ms
df5d108+dirty 1207.34 ms 1210.50 ms 3.16 ms
a50b33d+dirty 1207.11 ms 1212.10 ms 5.00 ms
3817909+dirty 1210.76 ms 1215.64 ms 4.89 ms

App size

Revision Plain With Sentry Diff
4953e94+dirty 3.38 MiB 4.73 MiB 1.35 MiB
df5d108+dirty 3.38 MiB 4.73 MiB 1.35 MiB
a50b33d+dirty 3.38 MiB 4.73 MiB 1.35 MiB
3817909+dirty 3.38 MiB 4.73 MiB 1.35 MiB

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

Android (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 362.29 ms 397.10 ms 34.82 ms
Size 43.94 MiB 48.94 MiB 5.00 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
4953e94+dirty 398.80 ms 431.81 ms 33.01 ms
3817909+dirty 357.52 ms 391.52 ms 34.00 ms
df5d108+dirty 434.82 ms 447.39 ms 12.57 ms
a50b33d+dirty 353.21 ms 398.48 ms 45.27 ms

App size

Revision Plain With Sentry Diff
4953e94+dirty 43.94 MiB 48.94 MiB 5.00 MiB
3817909+dirty 43.94 MiB 48.94 MiB 5.00 MiB
df5d108+dirty 43.94 MiB 48.94 MiB 5.00 MiB
a50b33d+dirty 43.94 MiB 48.94 MiB 5.00 MiB

@lucas-zimerman lucas-zimerman enabled auto-merge (squash) April 7, 2026 10:06
@lucas-zimerman lucas-zimerman merged commit cac4a4f into main Apr 7, 2026
33 of 71 checks passed
@lucas-zimerman lucas-zimerman deleted the lz/5957 branch April 7, 2026 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge Triggers the full CI test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error loading Metro config in Expo

2 participants