Skip to content

Conversation

@sebmarkbage
Copy link
Collaborator

@sebmarkbage sebmarkbage commented Aug 15, 2025

Stacked on #34210.

For inferred name of Promises, like an anonymous Promise passed to use() we currently take the function name of the first stack frame. #34162

This is usually good enough but if the Hook is in third party code then it can be a deep internal hook that you don't know anything about. This tries to skip ignore listed hooks and take the last ignore listed hook that was ignore listed. So that we get the name of the callsite into third party which is likely the name of the public API.

// node_modules/foo/bar.js

function useInternalHook() {
  use(promise);
}

export function useHook() {
  return useInternalHook();
}

This would now briefly show the name useInternalHook and then switch to useHook after source mapping.

This also tries to take the function name from the source mapped name but currently this is always empty since our source mapping doesn't extract the function name from source. So it always fallback to the generated source's function name.

@sebmarkbage sebmarkbage requested a review from eps1lon August 15, 2025 20:40
@meta-cla meta-cla bot added the CLA Signed label Aug 15, 2025
@github-actions github-actions bot added the React Core Team Opened by a member of the React Core Team label Aug 15, 2025
Comment on lines +35 to +42
for (let i = 0; i < inferNameFromStack.length; i++) {
const callSite: ReactCallSite = inferNameFromStack[i];
const [virtualFunctionName, virtualURL, virtualLine, virtualColumn] =
callSite;
const symbolicatedCallSite: null | SourceMappedLocation =
fetchFileWithCaching !== null
? use(
symbolicateSourceWithCache(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we seed these Promises before? This looks like a waterfall at a glance. Or is this intentional that we don't want to sourcemap eagerly in case the very first stack is already not ignored and we'd end up throwing away the later results?

@eps1lon eps1lon merged commit 11d7bcf into facebook:main Aug 21, 2025
467 of 469 checks passed
github-actions bot pushed a commit to code/lib-react that referenced this pull request Aug 24, 2025
github-actions bot pushed a commit to code/lib-react that referenced this pull request Aug 24, 2025
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