Skip to content

[LogBox] Parse bundling errors from Metro Dev Server and avoid symbolicating them#53452

Closed
krystofwoldrich wants to merge 5 commits into
react:mainfrom
krystofwoldrich:@krystofwoldrich/fix-logbox-bundling-errors-parsing
Closed

[LogBox] Parse bundling errors from Metro Dev Server and avoid symbolicating them#53452
krystofwoldrich wants to merge 5 commits into
react:mainfrom
krystofwoldrich:@krystofwoldrich/fix-logbox-bundling-errors-parsing

Conversation

@krystofwoldrich

@krystofwoldrich krystofwoldrich commented Aug 25, 2025

Copy link
Copy Markdown
Contributor

Summary:

This PR improves bundling (transform, syntax and internal Metro errors) handling.

Currently LogBox attaches synthetic stack trace to these errors which is misleading.

The synthetic stack trace also triggers symbolication which will fail causing long and duplicate logs in the metro dev server output.

This PR reuses LogBox Exception parsing for Log parsing as Metro errors are logged using console.error.

Changelog:

[GENERAL] [FIXED] - Parse Metro bundling errors and avoid symbolication

Test Plan:

  1. This issue only occurs with HMR bundling issues.
  2. Start dev server run the app.
  3. Create bundling issue, for example importing from non existing module
import "non-existing-module";
  1. Observe that the LogBox is showing clear message and doesn't contain any stack trace. ✅

Example after the PR:
Screenshot 2025-08-25 at 20 34 10

Before the PR:
Screenshot 2025-08-25 at 21 58 57
Screenshot 2025-08-25 at 21 58 54

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 25, 2025
@facebook-github-bot facebook-github-bot added p: Expo Partner: Expo Partner p: Sentry Partner: Sentry Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels Aug 25, 2025

@rickhanlonii rickhanlonii left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This doesn't seem right, we were definitely handling this in the past and there are some unit tests for it like this one.

In your screenshot it looks like there's a codeframe in the message. We attempt to detect any babel errors, and then we render the code frame in LogBox so you can see the issue in the app. This is better than your "after" screenshot, which only shows the message.

I think the problem here is that the error type is "UnableToResolveError" but it should be TransformError like in the test above. Do you know where that error type is coming from?

: undefined)
if (bundlingError) {
return LogBoxData.addLog(bundlingError);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is the wrong place for this

@krystofwoldrich

krystofwoldrich commented Aug 26, 2025

Copy link
Copy Markdown
Contributor Author

UnableToResolve Errors are coming directly from Metro, I don't see that as suspicious, but I might have missed something.

Inside of the application this error is received by the HMRClient which repacks and throws this error.

This thrown error is captured by EventTarget implementation.


Looking at this now, I agree and better place to change could be the HMRClient to avoid throwing the compilation error.

Changed in 7db31e2 (#53452)

@krystofwoldrich

Copy link
Copy Markdown
Contributor Author

Updated after this PR
Screenshot 2025-08-26 at 11 23 18

Repro krystofwoldrich/musical-octo-chainsaw@8850462

@krystofwoldrich

Copy link
Copy Markdown
Contributor Author

Hi @rickhanlonii,
I've simplified the fix, now it's only 2 lines, what do you think?

@cortinico cortinico requested a review from vzaidman October 16, 2025 18:36
@cortinico

Copy link
Copy Markdown
Contributor

cc @vzaidman for visibility also

@react-native-bot

react-native-bot commented Oct 16, 2025

Copy link
Copy Markdown
Collaborator

Warnings
⚠️ ❗ JavaScript API change detected - This PR commits an update to ReactNativeApi.d.ts, indicating a change to React Native's public JavaScript API. Please include a clear changelog message. This change will be subject to extra review.

This change was flagged as: BREAKING

Generated by 🚫 dangerJS against 93ac7db

@react-native-bot

Copy link
Copy Markdown
Collaborator

This PR is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@react-native-bot react-native-bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Apr 15, 2026
@react-native-bot

Copy link
Copy Markdown
Collaborator

This PR was closed because it has been stalled for 7 days with no activity.

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

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Expo Partner: Expo p: Sentry Partner: Sentry Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. Stale There has been a lack of activity on this issue and it may be closed soon.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants