@@ -1586,12 +1586,40 @@ function resolveErrorDev(
1586
1586
'resolveErrorDev should never be called in production mode. Use resolveErrorProd instead. This is a bug in React.' ,
1587
1587
) ;
1588
1588
}
1589
- // eslint-disable-next-line react-internal/prod-error-codes
1590
- const error = new Error (
1591
- message ||
1592
- 'An error occurred in the Server Components render but no message was provided' ,
1593
- ) ;
1594
- error . stack = stack ;
1589
+
1590
+ let error ;
1591
+ if ( ! enableOwnerStacks ) {
1592
+ // Executing Error within a native stack isn't really limited to owner stacks
1593
+ // but we gate it behind the same flag for now while iterating.
1594
+ // eslint-disable-next-line react-internal/prod-error-codes
1595
+ error = Error (
1596
+ message ||
1597
+ 'An error occurred in the Server Components render but no message was provided' ,
1598
+ ) ;
1599
+ error . stack = stack ;
1600
+ } else {
1601
+ const callStack = buildFakeCallStack (
1602
+ response ,
1603
+ stack ,
1604
+ // $FlowFixMe[incompatible-use]
1605
+ Error . bind (
1606
+ null ,
1607
+ message ||
1608
+ 'An error occurred in the Server Components render but no message was provided' ,
1609
+ ) ,
1610
+ ) ;
1611
+ const rootTask = response . _debugRootTask ;
1612
+ if ( rootTask != null ) {
1613
+ error = rootTask . run ( callStack ) ;
1614
+ } else {
1615
+ error = callStack ( ) ;
1616
+ }
1617
+ // Overriding the stack isn't really necessary at this point and maybe we should just
1618
+ // leave the native one. However, the native one gets printed unsource mapped with
1619
+ // reportError. If that's fixed it might be better to use the native one.
1620
+ error . stack = stack ;
1621
+ }
1622
+
1595
1623
( error : any ) . digest = digest ;
1596
1624
const errorWithDigest : ErrorWithDigest = ( error : any ) ;
1597
1625
const chunks = response . _chunks ;
0 commit comments