@@ -2016,37 +2016,21 @@ function renderRootSync(root: FiberRoot, lanes: Lanes) {
20162016 workInProgressSuspendedReason !== NotSuspended &&
20172017 workInProgress !== null
20182018 ) {
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.
20212027 const unitOfWork = workInProgress ;
20222028 const thrownValue = workInProgressThrownValue ;
20232029 workInProgressSuspendedReason = NotSuspended ;
20242030 workInProgressThrownValue = null ;
2031+ unwindSuspendedUnitOfWork ( unitOfWork , thrownValue ) ;
20252032
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.
20502034 }
20512035 workLoopSync ( ) ;
20522036 break ;
0 commit comments