Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix alwaysThrottleDisappearingFallbacks
  • Loading branch information
rickhanlonii committed Mar 25, 2024
commit fc72ca90750ff04f98d78230497d4e8b4174ccfd
5 changes: 4 additions & 1 deletion packages/react-reconciler/src/ReactFiberWorkLoop.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
useModernStrictMode,
disableLegacyContext,
alwaysThrottleRetries,
alwaysThrottleDisappearingFallbacks,
enableInfiniteRenderLoopDetection,
} from 'shared/ReactFeatureFlags';
import ReactSharedInternals from 'shared/ReactSharedInternals';
Expand Down Expand Up @@ -1128,7 +1129,9 @@ function finishConcurrentRender(
} else {
if (
includesOnlyRetries(lanes) &&
(alwaysThrottleRetries || exitStatus === RootSuspended)
(alwaysThrottleRetries ||
(alwaysThrottleDisappearingFallbacks && exitStatus === RootCompleted) ||
exitStatus === RootSuspended)
) {
// This render only included retries, no updates. Throttle committing
// retries so that we don't show too many loading states too quickly.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1757,7 +1757,13 @@ describe('ReactSuspenseWithNoopRenderer', () => {
// Restart and render the complete content.
await waitForAll(['A', 'B']);

if (gate(flags => flags.alwaysThrottleRetries)) {
if (
gate(
flags =>
flags.alwaysThrottleDisappearingFallbacks ||
flags.alwaysThrottleRetries,
)
) {
// Correct behavior:
//
// The tree will finish but we won't commit the result yet because the fallback appeared recently.
Expand Down Expand Up @@ -1848,11 +1854,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {

if (
// This behavior only applies if both flags are enabled.
gate(
flags =>
flags.alwaysThrottleDisappearingFallbacks &&
flags.alwaysThrottleRetries,
)
gate(flags => flags.alwaysThrottleDisappearingFallbacks)
) {
// B should not commit yet. Even though it's been a long time since its
// fallback was shown, it hasn't been long since A appeared. So B's
Expand Down