@@ -2016,37 +2016,21 @@ function renderRootSync(root: FiberRoot, lanes: Lanes) {
2016
2016
workInProgressSuspendedReason !== NotSuspended &&
2017
2017
workInProgress !== null
2018
2018
) {
2019
- // The work loop is suspended. We need to either unwind the stack or
2020
- // replay the suspended component.
2019
+ // The work loop is suspended. During a synchronous render, we don't
2020
+ // yield to the main thread. Immediately unwind the stack. This will
2021
+ // trigger either a fallback or an error boundary.
2022
+ // TODO: For discrete and "default" updates (anything that's not
2023
+ // flushSync), we want to wait for the microtasks the flush before
2024
+ // unwinding. Will probably implement this using renderRootConcurrent,
2025
+ // or merge renderRootSync and renderRootConcurrent into the same
2026
+ // function and fork the behavior some other way.
2021
2027
const unitOfWork = workInProgress ;
2022
2028
const thrownValue = workInProgressThrownValue ;
2023
2029
workInProgressSuspendedReason = NotSuspended ;
2024
2030
workInProgressThrownValue = null ;
2031
+ unwindSuspendedUnitOfWork ( unitOfWork , thrownValue ) ;
2025
2032
2026
- // TODO: This check is only here to account for thenables that
2027
- // synchronously resolve. Otherwise we would always unwind when
2028
- // rendering with renderRootSync. (In the future, discrete updates will
2029
- // use renderRootConcurrent instead.) We should account for
2030
- // synchronously resolved thenables before hitting this path.
2031
- switch ( workInProgressSuspendedReason ) {
2032
- case SuspendedOnError : {
2033
- // Unwind then continue with the normal work loop.
2034
- unwindSuspendedUnitOfWork ( unitOfWork , thrownValue ) ;
2035
- break ;
2036
- }
2037
- default : {
2038
- const wasPinged =
2039
- workInProgressSuspendedThenableState !== null &&
2040
- isThenableStateResolved ( workInProgressSuspendedThenableState ) ;
2041
- if ( wasPinged ) {
2042
- replaySuspendedUnitOfWork ( unitOfWork , thrownValue ) ;
2043
- } else {
2044
- unwindSuspendedUnitOfWork ( unitOfWork , thrownValue ) ;
2045
- }
2046
- // Continue with the normal work loop.
2047
- break ;
2048
- }
2049
- }
2033
+ // Continue with the normal work loop.
2050
2034
}
2051
2035
workLoopSync ( ) ;
2052
2036
break ;
0 commit comments