Skip to content

[Flight] module.findSourceMap compatible source URLs when findSourceMapURL is not implemented #33969

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

eps1lon
Copy link
Collaborator

@eps1lon eps1lon commented Jul 23, 2025

Implementing findSourceMapURL is still preferred since it prevents debuggers from overriding the source in the sources panel

When Client and Server run in the same VM, the Client could reuse the original source URL to get the source map. This isn't possible at the moment since React alters the value from StructuredCallSite#getScriptNameOrSourceURL in a way that is incompatible with how Node.js uses this value as a key in its internal source map cache. This mostly works for files with just alphanumeric characters. But it breaks when e.g. square brackets or spaces are used in file paths.

The only alternative in Node.js is implementing findSourceMapURL by getting the source map payload based on the original source URL and serializing that into a data: URL. Not only is this wasteful due to the added serialization+deserialization step, it also significantly increases memory consumption since Node.js holds onto source maps forever and doesn't deduplicate sourcemaps on source mapping URLs. Deduplication based on source map URLs is definitely something we should contribute upstream regardless. GCing source maps may be more involved. And then we'd still have the overhead of added serialization+deserialization.

Alternate to #33731

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