@@ -168,7 +168,7 @@ function getStack(error: Error): string {
168
168
169
169
function initCallComponentFrame ( ) : string {
170
170
// Extract the stack frame of the callComponentInDEV function.
171
- const error = callComponentInDEV ( Error , 'react-stack-top-frame' , { } ) ;
171
+ const error = callComponentInDEV ( Error , 'react-stack-top-frame' , { } , null ) ;
172
172
const stack = getStack ( error ) ;
173
173
const startIdx = stack . startsWith ( 'Error: react-stack-top-frame\n' ) ? 29 : 0 ;
174
174
const endIdx = stack . indexOf ( '\n' , startIdx ) ;
@@ -991,20 +991,36 @@ function callComponentInDEV<Props, R>(
991
991
Component: (p: Props, arg: void) => R ,
992
992
props : Props ,
993
993
componentDebugInfo : ReactComponentInfo ,
994
+ debugTask : null | ConsoleTask ,
994
995
) : R {
995
996
// The secondArg is always undefined in Server Components since refs error early.
996
997
const secondArg = undefined ;
997
998
setCurrentOwner ( componentDebugInfo ) ;
998
999
try {
999
1000
if ( supportsComponentStorage ) {
1000
1001
// Run the component in an Async Context that tracks the current owner.
1002
+ if ( enableOwnerStacks && debugTask ) {
1003
+ return debugTask . run (
1004
+ // $FlowFixMe[method-unbinding]
1005
+ componentStorage . run . bind (
1006
+ componentStorage ,
1007
+ componentDebugInfo ,
1008
+ Component ,
1009
+ props ,
1010
+ secondArg ,
1011
+ ) ,
1012
+ ) ;
1013
+ }
1001
1014
return componentStorage . run (
1002
1015
componentDebugInfo ,
1003
1016
Component ,
1004
1017
props ,
1005
1018
secondArg ,
1006
1019
) ;
1007
1020
} else {
1021
+ if ( enableOwnerStacks && debugTask ) {
1022
+ return debugTask . run ( Component . bind ( null , props, secondArg) ) ;
1023
+ }
1008
1024
return Component ( props , secondArg ) ;
1009
1025
}
1010
1026
} finally {
@@ -1028,6 +1044,7 @@ function renderFunctionComponent<Props>(
1028
1044
props : Props ,
1029
1045
owner : null | ReactComponentInfo , // DEV-only
1030
1046
stack : null | string , // DEV-only
1047
+ debugTask : null | ConsoleTask , // DEV-only
1031
1048
validated : number , // DEV-only
1032
1049
) : ReactJSONValue {
1033
1050
// Reset the task's thenable state before continuing, so that if a later
@@ -1075,11 +1092,22 @@ function renderFunctionComponent<Props>(
1075
1092
task . environmentName = componentEnv ;
1076
1093
1077
1094
if ( enableOwnerStacks ) {
1078
- warnForMissingKey ( request , key , validated , componentDebugInfo ) ;
1095
+ warnForMissingKey (
1096
+ request ,
1097
+ key ,
1098
+ validated ,
1099
+ componentDebugInfo ,
1100
+ debugTask ,
1101
+ ) ;
1079
1102
}
1080
1103
}
1081
1104
prepareToUseHooksForComponent ( prevThenableState , componentDebugInfo ) ;
1082
- result = callComponentInDEV ( Component , props , componentDebugInfo ) ;
1105
+ result = callComponentInDEV (
1106
+ Component ,
1107
+ props ,
1108
+ componentDebugInfo ,
1109
+ debugTask ,
1110
+ ) ;
1083
1111
} else {
1084
1112
prepareToUseHooksForComponent ( prevThenableState , null ) ;
1085
1113
// The secondArg is always undefined in Server Components since refs error early.
@@ -1235,6 +1263,7 @@ function warnForMissingKey(
1235
1263
key : null | string ,
1236
1264
validated : number ,
1237
1265
componentDebugInfo : ReactComponentInfo ,
1266
+ debugTask : null | ConsoleTask ,
1238
1267
) : void {
1239
1268
if ( __DEV__ ) {
1240
1269
if ( validated !== 2 ) {
@@ -1267,6 +1296,7 @@ function warnForMissingKey(
1267
1296
} ,
1268
1297
null,
1269
1298
componentDebugInfo,
1299
+ debugTask,
1270
1300
);
1271
1301
}
1272
1302
}
@@ -1482,6 +1512,7 @@ function renderElement(
1482
1512
props : any ,
1483
1513
owner : null | ReactComponentInfo , // DEV only
1484
1514
stack : null | string , // DEV only
1515
+ debugTask : null | ConsoleTask , // DEV only
1485
1516
validated : number , // DEV only
1486
1517
) : ReactJSONValue {
1487
1518
if ( ref !== null && ref !== undefined ) {
@@ -1514,6 +1545,7 @@ function renderElement(
1514
1545
props ,
1515
1546
owner ,
1516
1547
stack ,
1548
+ debugTask ,
1517
1549
validated ,
1518
1550
) ;
1519
1551
} else if ( type === REACT_FRAGMENT_TYPE && key === null ) {
@@ -1562,6 +1594,7 @@ function renderElement(
1562
1594
props ,
1563
1595
owner ,
1564
1596
stack ,
1597
+ debugTask ,
1565
1598
validated ,
1566
1599
) ;
1567
1600
}
@@ -1574,6 +1607,7 @@ function renderElement(
1574
1607
props ,
1575
1608
owner ,
1576
1609
stack ,
1610
+ debugTask ,
1577
1611
validated ,
1578
1612
) ;
1579
1613
}
@@ -1587,6 +1621,7 @@ function renderElement(
1587
1621
props ,
1588
1622
owner ,
1589
1623
stack ,
1624
+ debugTask ,
1590
1625
validated ,
1591
1626
) ;
1592
1627
}
@@ -2190,6 +2225,7 @@ function renderModelDestructive(
2190
2225
? element . _debugStack
2191
2226
: filterDebugStack ( element . _debugStack )
2192
2227
: null ,
2228
+ __DEV__ && enableOwnerStacks ? element . _debugTask : null ,
2193
2229
__DEV__ && enableOwnerStacks ? element . _store . validated : 0 ,
2194
2230
) ;
2195
2231
if (
0 commit comments