Skip to content

Conversation

eps1lon
Copy link
Collaborator

@eps1lon eps1lon commented Aug 26, 2025

Symbolicating with Index Source Maps needs to consider that the mappings in a section are relative to its offset.

Before:
CleanShot 2025-08-26 at 14 39 18@2x

After:

CleanShot 2025-08-26 at 14 44 25@2x

@meta-cla meta-cla bot added the CLA Signed label Aug 26, 2025
@github-actions github-actions bot added the React Core Team Opened by a member of the React Core Team label Aug 26, 2025
Comment on lines +228 to +230
// The mappings in a Source Map section are relative to the section offset.
columnNumber: columnNumber - section.offsetColumn0,
lineNumber: lineNumber - section.offsetLine0,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the essence of the fix. The rest is just me being extra cautious with off-by-one errors. The implementation to find the relevant section is the same we're using in Next.js: https://github.com/vercel/next.js/blob/62f9611facd13ca7720b8fcfbc609c948a0563ba/packages/next/src/server/lib/source-maps.ts#L75-L97

Copy link
Contributor

Choose a reason for hiding this comment

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

The rest is just me being extra cautious with off-by-one errors.

Absolutely the correct approach when dealing with source maps; thank you for that!

@eps1lon eps1lon requested a review from hoxyq August 26, 2025 12:48
+map: MixedSourceMap,
+offsetColumn0: number,
+offsetLine0: number,
+map: BasicSourceMap,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

drive-by fix. Index Source Maps can't be nested: https://tc39.es/ecma426/#json-sections-map

@eps1lon eps1lon marked this pull request as ready for review August 26, 2025 12:52
Comment on lines +228 to +230
// The mappings in a Source Map section are relative to the section offset.
columnNumber: columnNumber - section.offsetColumn0,
lineNumber: lineNumber - section.offsetLine0,
Copy link
Contributor

Choose a reason for hiding this comment

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

The rest is just me being extra cautious with off-by-one errors.

Absolutely the correct approach when dealing with source maps; thank you for that!

@eps1lon eps1lon merged commit ad4ecb6 into facebook:main Aug 26, 2025
250 checks passed
@eps1lon eps1lon deleted the sebbie/08-26-_devtools_fix_symbolication_with_index_source_maps branch August 26, 2025 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants