Skip to content

Commit cae764c

Browse files
authored
Revert "[Re-land] Make prerendering always non-blocking (#31268)" (#31355)
This reverts commit 6c4bbc7. It looked like the bug we found on the original land was related to broken product code. But through landing #31268 we found additional bugs internally. Since disabling the feature flag does not fix the bugs, we have to revert again to unblock the sync. We can continue to debug with our internal build.
1 parent d19ba8e commit cae764c

File tree

6 files changed

+126
-278
lines changed

6 files changed

+126
-278
lines changed

Diff for: packages/react-dom/src/__tests__/ReactDOMFiberAsync-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ describe('ReactDOMFiberAsync', () => {
744744
// Because it suspended, it remains on the current path
745745
expect(div.textContent).toBe('/path/a');
746746
});
747-
assertLog(gate('enableSiblingPrerendering') ? ['Suspend! [/path/b]'] : []);
747+
assertLog([]);
748748

749749
await act(async () => {
750750
resolvePromise();

Diff for: packages/react-reconciler/src/ReactFiberLane.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -765,14 +765,12 @@ export function markRootSuspended(
765765
root: FiberRoot,
766766
suspendedLanes: Lanes,
767767
spawnedLane: Lane,
768-
didAttemptEntireTree: boolean,
768+
didSkipSuspendedSiblings: boolean,
769769
) {
770-
// TODO: Split this into separate functions for marking the root at the end of
771-
// a render attempt versus suspending while the root is still in progress.
772770
root.suspendedLanes |= suspendedLanes;
773771
root.pingedLanes &= ~suspendedLanes;
774772

775-
if (enableSiblingPrerendering && didAttemptEntireTree) {
773+
if (enableSiblingPrerendering && !didSkipSuspendedSiblings) {
776774
// Mark these lanes as warm so we know there's nothing else to work on.
777775
root.warmLanes |= suspendedLanes;
778776
} else {

Diff for: packages/react-reconciler/src/ReactFiberRootScheduler.js

+4-16
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import {
1818
disableSchedulerTimeoutInWorkLoop,
1919
enableProfilerTimer,
2020
enableProfilerNestedUpdatePhase,
21-
enableSiblingPrerendering,
2221
} from 'shared/ReactFeatureFlags';
2322
import {
2423
NoLane,
@@ -30,7 +29,6 @@ import {
3029
markStarvedLanesAsExpired,
3130
claimNextTransitionLane,
3231
getNextLanesToFlushSync,
33-
checkIfRootIsPrerendering,
3432
} from './ReactFiberLane';
3533
import {
3634
CommitContext,
@@ -208,10 +206,7 @@ function flushSyncWorkAcrossRoots_impl(
208206
? workInProgressRootRenderLanes
209207
: NoLanes,
210208
);
211-
if (
212-
includesSyncLane(nextLanes) &&
213-
!checkIfRootIsPrerendering(root, nextLanes)
214-
) {
209+
if (includesSyncLane(nextLanes)) {
215210
// This root has pending sync work. Flush it now.
216211
didPerformSomeWork = true;
217212
performSyncWorkOnRoot(root, nextLanes);
@@ -346,13 +341,7 @@ function scheduleTaskForRootDuringMicrotask(
346341
}
347342

348343
// Schedule a new callback in the host environment.
349-
if (
350-
includesSyncLane(nextLanes) &&
351-
// If we're prerendering, then we should use the concurrent work loop
352-
// even if the lanes are synchronous, so that prerendering never blocks
353-
// the main thread.
354-
!(enableSiblingPrerendering && checkIfRootIsPrerendering(root, nextLanes))
355-
) {
344+
if (includesSyncLane(nextLanes)) {
356345
// Synchronous work is always flushed at the end of the microtask, so we
357346
// don't need to schedule an additional task.
358347
if (existingCallbackNode !== null) {
@@ -386,10 +375,9 @@ function scheduleTaskForRootDuringMicrotask(
386375

387376
let schedulerPriorityLevel;
388377
switch (lanesToEventPriority(nextLanes)) {
389-
// Scheduler does have an "ImmediatePriority", but now that we use
390-
// microtasks for sync work we no longer use that. Any sync work that
391-
// reaches this path is meant to be time sliced.
392378
case DiscreteEventPriority:
379+
schedulerPriorityLevel = ImmediateSchedulerPriority;
380+
break;
393381
case ContinuousEventPriority:
394382
schedulerPriorityLevel = UserBlockingSchedulerPriority;
395383
break;

0 commit comments

Comments
 (0)