Skip to content
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

Fix breakpoints in RN 76 apps #644

Merged
merged 3 commits into from
Oct 22, 2024
Merged

Fix breakpoints in RN 76 apps #644

merged 3 commits into from
Oct 22, 2024

Conversation

kmagiera
Copy link
Member

This PR fixes an issue with breakpoints in RN 76 apps.

There were two core issues related to the breakpoints:

  1. We'd not process metro-watchFolders aliases properly, the support for this source map alias was missing
  2. We were not updating breakpoints with hermes after hot reload of individual files

As the reason for (1) was simply that we didn't add the implementation for watch folders, the reason for the bug related to (2) is more evolved: the culprit was in updateBreakpointsInSource method, were we'd use mapping.source directly from the source-map consumer to locate existing breakpoints. Because the stored breakpoints would always use local filesystem URLs, with the source using aliased name, we'd never locate the breakpoint that we should update. As a consequence, the breakpoints that were set for the files which then got hot reloaded, would never be set to stop at those newly loaded scripts.

To solve (2), we are now transforming source from the source map consumer into the absolute file path before we perform breakpoint lookup.

In order to fix (1), we are adding a more sophisticated mapping mechanims:

  1. instead of absoluteProjectPath and projectPathAlias we now keep an array of source map aliases pairs
  2. we use that new array to map from source map aliased path into filesystem paths
  3. the map is constructed at the moment of creating debug session and following the way metro does it we set aliases for metro-project and metro-watchFolders
  4. we extract the watch folders using metro config overrides, then use metro's stdout to pass that back to the extension process (same technique that we use for passing metro's port numer). In addition we accommodate for metro internals that prepend project root to watch folder after the config is loaded.

How Has This Been Tested:

  1. Run RN 76 example (need Update test example for RN 76 to latest RC #641 for this)
  2. Set breakpoint somewhere in the code
  3. Check it stops at the breakpoint
  4. Add some lines before the breakpoint
  5. Check again to see that the debugger stops at the altered breakpoint location (this was broken before this change)
  6. Test debugger in RN 75 to verify this didn't break old debugger

Copy link

vercel bot commented Oct 21, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
radon-ide ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 22, 2024 3:58pm

Copy link
Contributor

@p-malecki p-malecki left a comment

Choose a reason for hiding this comment

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

I approve. It should also be tested on Windows, as the debugger and breakpoints did not function correctly there in projects with RN 75 and RN 76.

@p-malecki
Copy link
Contributor

It appears the problem still exists on Windows, debugger does not stop on breakpoints. Tested on RN 76 app after #641 update.

Recording.2024-10-22.161849.mp4

@kmagiera kmagiera merged commit 8dc5db9 into main Oct 22, 2024
3 checks passed
@kmagiera kmagiera deleted the kmagiera/fix-breakpoints-76 branch October 22, 2024 16:12
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.

2 participants