GeezerVison is showing github.com — Revert #24236 (Don't recreate the same fallback on the client if hydr… · react/react@bd4784c
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js +23-15Lines changed: 23 additions & 15 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -869,16 +869,15 @@ describe('ReactDOMFizzServer', () => { | 869 | 869 | }); | 870 | 870 |
| 871 | 871 | // We still can't render it on the client. | 872 | | - expect(Scheduler).toFlushAndYield([]); | 873 | | - expect(getVisibleChildren(container)).toEqual(<div>Loading...</div>); | 874 | | - | 875 | | - // We now resolve it on the client. | 876 | | - resolveText('Hello'); | 877 | | - | 878 | 872 | expect(Scheduler).toFlushAndYield([ | 879 | 873 | 'The server could not finish this Suspense boundary, likely due to an ' + | 880 | 874 | 'error during server rendering. Switched to client rendering.', | 881 | 875 | ]); | | 876 | + expect(getVisibleChildren(container)).toEqual(<div>Loading...</div>); | | 877 | + | | 878 | + // We now resolve it on the client. | | 879 | + resolveText('Hello'); | | 880 | + Scheduler.unstable_flushAll(); | 882 | 881 |
| 883 | 882 | // The client rendered HTML is now in place. | 884 | 883 | expect(getVisibleChildren(container)).toEqual( | @@ -2189,7 +2188,10 @@ describe('ReactDOMFizzServer', () => { | 2189 | 2188 | }, | 2190 | 2189 | ); | 2191 | 2190 |
| | 2191 | + // Disabled because of a WWW late mutations regression. | | 2192 | + // We may want to re-enable this if we figure out why. | 2192 | 2193 | // @gate experimental | | 2194 | + // @gate FIXME | 2193 | 2195 | it('does not recreate the fallback if server errors and hydration suspends', async () => { | 2194 | 2196 | let isClient = false; | 2195 | 2197 |
| @@ -2268,7 +2270,10 @@ describe('ReactDOMFizzServer', () => { | 2268 | 2270 | ); | 2269 | 2271 | }); | 2270 | 2272 |
| | 2273 | + // Disabled because of a WWW late mutations regression. | | 2274 | + // We may want to re-enable this if we figure out why. | 2271 | 2275 | // @gate experimental | | 2276 | + // @gate FIXME | 2272 | 2277 | it( | 2273 | 2278 | 'does not recreate the fallback if server errors and hydration suspends ' + | 2274 | 2279 | 'and root receives a transition', | @@ -2364,7 +2369,10 @@ describe('ReactDOMFizzServer', () => { | 2364 | 2369 | }, | 2365 | 2370 | ); | 2366 | 2371 |
| | 2372 | + // Disabled because of a WWW late mutations regression. | | 2373 | + // We may want to re-enable this if we figure out why. | 2367 | 2374 | // @gate experimental | | 2375 | + // @gate FIXME | 2368 | 2376 | it( | 2369 | 2377 | 'recreates the fallback if server errors and hydration suspends but ' + | 2370 | 2378 | 'client receives new props', | @@ -2542,25 +2550,25 @@ describe('ReactDOMFizzServer', () => { | 2542 | 2550 | }, | 2543 | 2551 | }); | 2544 | 2552 |
| 2545 | | - // An error happened but instead of surfacing it to the UI, we suspended. | 2546 | | - expect(Scheduler).toFlushAndYield([]); | | 2553 | + // An error logged but instead of surfacing it to the UI, we switched | | 2554 | + // to client rendering. | | 2555 | + expect(Scheduler).toFlushAndYield([ | | 2556 | + 'Hydration error', | | 2557 | + 'There was an error while hydrating this Suspense boundary. Switched ' + | | 2558 | + 'to client rendering.', | | 2559 | + ]); | 2547 | 2560 | expect(getVisibleChildren(container)).toEqual( | 2548 | 2561 | <div> | 2549 | 2562 | <span /> | 2550 | | - <span>Yay!</span> | | 2563 | + Loading... | 2551 | 2564 | <span /> | 2552 | 2565 | </div>, | 2553 | 2566 | ); | 2554 | 2567 |
| 2555 | 2568 | await act(async () => { | 2556 | 2569 | resolveText('Yay!'); | 2557 | 2570 | }); | 2558 | | - expect(Scheduler).toFlushAndYield([ | 2559 | | - 'Yay!', | 2560 | | - 'Hydration error', | 2561 | | - 'There was an error while hydrating this Suspense boundary. Switched ' + | 2562 | | - 'to client rendering.', | 2563 | | - ]); | | 2571 | + expect(Scheduler).toFlushAndYield(['Yay!']); | 2564 | 2572 | expect(getVisibleChildren(container)).toEqual( | 2565 | 2573 | <div> | 2566 | 2574 | <span /> | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-dom/src/__tests__/ReactDOMHydrationDiff-test.js +12-6Lines changed: 12 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -792,7 +792,7 @@ describe('ReactDOMServerHydration', () => { | 792 | 792 | }); | 793 | 793 |
| 794 | 794 | // @gate __DEV__ | 795 | | - it('does not warn when client renders an extra node inside Suspense fallback', () => { | | 795 | + it('warns when client renders an extra node inside Suspense fallback', () => { | 796 | 796 | function Mismatch({isClient}) { | 797 | 797 | return ( | 798 | 798 | <div className="parent"> | @@ -809,12 +809,15 @@ describe('ReactDOMServerHydration', () => { | 809 | 809 | </div> | 810 | 810 | ); | 811 | 811 | } | 812 | | - // There is no error because we don't actually hydrate fallbacks. | 813 | | - expect(testMismatch(Mismatch)).toMatchInlineSnapshot(`Array []`); | | 812 | + expect(testMismatch(Mismatch)).toMatchInlineSnapshot(` | | 813 | + Array [ | | 814 | + "Caught [The server could not finish this Suspense boundary, likely due to an error during server rendering. Switched to client rendering.]", | | 815 | + ] | | 816 | + `); | 814 | 817 | }); | 815 | 818 |
| 816 | 819 | // @gate __DEV__ | 817 | | - it('does not warn when server renders an extra node inside Suspense fallback', () => { | | 820 | + it('warns when server renders an extra node inside Suspense fallback', () => { | 818 | 821 | function Mismatch({isClient}) { | 819 | 822 | return ( | 820 | 823 | <div className="parent"> | @@ -831,8 +834,11 @@ describe('ReactDOMServerHydration', () => { | 831 | 834 | </div> | 832 | 835 | ); | 833 | 836 | } | 834 | | - // There is no error because we don't actually hydrate fallbacks. | 835 | | - expect(testMismatch(Mismatch)).toMatchInlineSnapshot(`Array []`); | | 837 | + expect(testMismatch(Mismatch)).toMatchInlineSnapshot(` | | 838 | + Array [ | | 839 | + "Caught [The server could not finish this Suspense boundary, likely due to an error during server rendering. Switched to client rendering.]", | | 840 | + ] | | 841 | + `); | 836 | 842 | }); | 837 | 843 | }); | 838 | 844 |
| |
Collapse file Copy file name to clipboardExpand all lines: packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js +4-1Lines changed: 4 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -2115,7 +2115,10 @@ describe('ReactDOMServerPartialHydration', () => { | 2115 | 2115 | }); | 2116 | 2116 |
| 2117 | 2117 | suspend = true; | 2118 | | - expect(Scheduler).toFlushAndYield([]); | | 2118 | + expect(Scheduler).toFlushAndYield([ | | 2119 | + 'The server could not finish this Suspense boundary, likely due to ' + | | 2120 | + 'an error during server rendering. Switched to client rendering.', | | 2121 | + ]); | 2119 | 2122 |
| 2120 | 2123 | // We haven't hydrated the second child but the placeholder is still in the list. | 2121 | 2124 | expect(container.textContent).toBe('ALoading B'); | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberBeginWork.new.js -1Lines changed: 0 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -2270,7 +2270,6 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { | 2270 | 2270 | } else { | 2271 | 2271 | // Suspended but we should no longer be in dehydrated mode. | 2272 | 2272 | // Therefore we now have to render the fallback. | 2273 | | - renderDidSuspendDelayIfPossible(); | 2274 | 2273 | const nextPrimaryChildren = nextProps.children; | 2275 | 2274 | const nextFallbackChildren = nextProps.fallback; | 2276 | 2275 | const fallbackChildFragment = mountSuspenseFallbackAfterRetryWithoutHydrating( | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberBeginWork.old.js -1Lines changed: 0 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -2270,7 +2270,6 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { | 2270 | 2270 | } else { | 2271 | 2271 | // Suspended but we should no longer be in dehydrated mode. | 2272 | 2272 | // Therefore we now have to render the fallback. | 2273 | | - renderDidSuspendDelayIfPossible(); | 2274 | 2273 | const nextPrimaryChildren = nextProps.children; | 2275 | 2274 | const nextFallbackChildren = nextProps.fallback; | 2276 | 2275 | const fallbackChildFragment = mountSuspenseFallbackAfterRetryWithoutHydrating( | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberLane.new.js +3Lines changed: 3 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -459,6 +459,9 @@ export function includesOnlyNonUrgentLanes(lanes: Lanes) { | 459 | 459 | const UrgentLanes = SyncLane | InputContinuousLane | DefaultLane; | 460 | 460 | return (lanes & UrgentLanes) === NoLanes; | 461 | 461 | } | | 462 | +export function includesOnlyTransitions(lanes: Lanes) { | | 463 | + return (lanes & TransitionLanes) === lanes; | | 464 | +} | 462 | 465 |
| 463 | 466 | export function includesBlockingLane(root: FiberRoot, lanes: Lanes) { | 464 | 467 | if ( | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberLane.old.js +3Lines changed: 3 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -459,6 +459,9 @@ export function includesOnlyNonUrgentLanes(lanes: Lanes) { | 459 | 459 | const UrgentLanes = SyncLane | InputContinuousLane | DefaultLane; | 460 | 460 | return (lanes & UrgentLanes) === NoLanes; | 461 | 461 | } | | 462 | +export function includesOnlyTransitions(lanes: Lanes) { | | 463 | + return (lanes & TransitionLanes) === lanes; | | 464 | +} | 462 | 465 |
| 463 | 466 | export function includesBlockingLane(root: FiberRoot, lanes: Lanes) { | 464 | 467 | if ( | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberWorkLoop.new.js +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -131,7 +131,7 @@ import { | 131 | 131 | pickArbitraryLane, | 132 | 132 | includesNonIdleWork, | 133 | 133 | includesOnlyRetries, | 134 | | - includesOnlyNonUrgentLanes, | | 134 | + includesOnlyTransitions, | 135 | 135 | includesBlockingLane, | 136 | 136 | includesExpiredLane, | 137 | 137 | getNextLanes, | @@ -1150,7 +1150,7 @@ function finishConcurrentRender(root, exitStatus, lanes) { | 1150 | 1150 | case RootSuspendedWithDelay: { | 1151 | 1151 | markRootSuspended(root, lanes); | 1152 | 1152 |
| 1153 | | - if (includesOnlyNonUrgentLanes(lanes)) { | | 1153 | + if (includesOnlyTransitions(lanes)) { | 1154 | 1154 | // This is a transition, so we should exit without committing a | 1155 | 1155 | // placeholder and without scheduling a timeout. Delay indefinitely | 1156 | 1156 | // until we receive more data. | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberWorkLoop.old.js +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -131,7 +131,7 @@ import { | 131 | 131 | pickArbitraryLane, | 132 | 132 | includesNonIdleWork, | 133 | 133 | includesOnlyRetries, | 134 | | - includesOnlyNonUrgentLanes, | | 134 | + includesOnlyTransitions, | 135 | 135 | includesBlockingLane, | 136 | 136 | includesExpiredLane, | 137 | 137 | getNextLanes, | @@ -1150,7 +1150,7 @@ function finishConcurrentRender(root, exitStatus, lanes) { | 1150 | 1150 | case RootSuspendedWithDelay: { | 1151 | 1151 | markRootSuspended(root, lanes); | 1152 | 1152 |
| 1153 | | - if (includesOnlyNonUrgentLanes(lanes)) { | | 1153 | + if (includesOnlyTransitions(lanes)) { | 1154 | 1154 | // This is a transition, so we should exit without committing a | 1155 | 1155 | // placeholder and without scheduling a timeout. Delay indefinitely | 1156 | 1156 | // until we receive more data. | |
|