Skip to content

Commit

Permalink
Add special placeholder for unknown owners
Browse files Browse the repository at this point in the history
Not sure about this one. It'll point into React code i.e. node_modules and should be
ignore-listed by modern frameworks.
  • Loading branch information
eps1lon committed Mar 5, 2025
1 parent edcfcb8 commit f134542
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ describe('ReactOwnerStacks', () => {
let i = 0;
i <
siblingsBeforeStackOne -
// One built-in JSX callsite for the unknown Owner Stack
1 -
// Number of JSX callsites before this render
1 -
// Stop so that OwnerStackOne will be right before cutoff
Expand Down Expand Up @@ -139,7 +141,7 @@ describe('ReactOwnerStacks', () => {
stackOne: '\n in App (at **)',
stackTwo: __VARIANT__
? // captured right after cutoff
''
'\n in UnknownOwner (at **)'
: '\n in App (at **)',
});

Expand Down
27 changes: 19 additions & 8 deletions packages/react/src/jsx/ReactJSXElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,20 @@ function getOwner() {
let specialPropKeyWarningShown;
let didWarnAboutElementRef;
let didWarnAboutOldJSXRuntime;
let unknownOwnerDebugStack;
let unknownOwnerDebugTask;

if (__DEV__) {
didWarnAboutElementRef = {};
const unknownOwnerElement = {
'react-stack-bottom-frame': () => {
return (function UnknownOwner() {
return jsxDEV(() => null, {}, null);
})();
},
}['react-stack-bottom-frame']();
unknownOwnerDebugStack = unknownOwnerElement._debugStack;
unknownOwnerDebugTask = unknownOwnerElement._debugTask;
}

function hasValidRef(config) {
Expand Down Expand Up @@ -396,12 +407,12 @@ export function jsxProdSignatureRunningInDevWithDynamicChildren(
__DEV__ &&
(recentlyCreatedOwnerStacks++ < ownerStackLimit
? Error('react-stack-top-frame')
: null),
: unknownOwnerDebugStack),
// TODO: If task.run is not the bottleneck, reuse a placeholder task to indicate the deop.
__DEV__ &&
(recentlyCreatedDebugTasks++ < debugTaskLimit
? createTask(getTaskName(type))
: null),
: unknownOwnerDebugTask),
);
}
}
Expand All @@ -426,12 +437,12 @@ export function jsxProdSignatureRunningInDevWithStaticChildren(
__DEV__ &&
(recentlyCreatedOwnerStacks++ < ownerStackLimit
? Error('react-stack-top-frame')
: null),
: unknownOwnerDebugStack),
// TODO: If task.run is not the bottleneck, reuse a placeholder task to indicate the deop.
__DEV__ &&
(recentlyCreatedDebugTasks++ < debugTaskLimit
? createTask(getTaskName(type))
: null),
: unknownOwnerDebugTask),
);
}
}
Expand All @@ -456,12 +467,12 @@ export function jsxDEV(type, config, maybeKey, isStaticChildren, source, self) {
__DEV__ &&
(recentlyCreatedOwnerStacks++ < ownerStackLimit
? Error('react-stack-top-frame')
: null),
: unknownOwnerDebugStack),
// TODO: If task.run is not the bottleneck, reuse a placeholder task to indicate the deop.
__DEV__ &&
(recentlyCreatedDebugTasks++ < debugTaskLimit
? createTask(getTaskName(type))
: null),
: unknownOwnerDebugTask),
);
}

Expand Down Expand Up @@ -740,12 +751,12 @@ export function createElement(type, config, children) {
__DEV__ &&
(recentlyCreatedOwnerStacks++ < ownerStackLimit
? Error('react-stack-top-frame')
: null),
: unknownOwnerDebugStack),
// TODO: If task.run is not the bottleneck, reuse a placeholder task to indicate the deop.
__DEV__ &&
(recentlyCreatedDebugTasks++ < debugTaskLimit
? createTask(getTaskName(type))
: null),
: unknownOwnerDebugTask),
);
}

Expand Down

0 comments on commit f134542

Please sign in to comment.