Skip to content

Conversation

@rickhanlonii
Copy link
Member

@rickhanlonii rickhanlonii commented Apr 29, 2023

I can't figure out what reproduces this via e2e tests, but this is the root data structure that causes it so I wrote a unit test to demonstrate it. It happens when root === workInProgress and the workInProgressRootRenderLanes is the sync lane.

In that case, the nextLane is the sync lane for the work in progress, so we go into performSyncWorkOnRoot:

// paraphrased
do {
  let = didPerformSomeWork = false
  const nextLanes = getNextLanes(
    root,
    // 🚨 workInProgressRoot includes sync lane
    root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes,
    );
    if (includesSyncLane(nextLanes)) {
      // TODO: Pass nextLanes as an argument instead of computing it again
      // inside performSyncWorkOnRoot.
      didPerformSomeWork = true;
      performSyncWorkOnRoot(root);
    }
    // ...  
} while (didPerformSomeWork) // 🚨 Always true

But inside performSyncWorkOnRoot, these lines early return and do not account for the work in progress lanes:

  // TODO: This was already computed in the caller. Pass it as an argument.
  let lanes = getNextLanes(root, NoLanes);  // 🚨 Doesn't include workInProgressRoot
  if (!includesSyncLane(lanes)) {
    // There's no remaining sync work left.
    ensureRootIsScheduled(root);
    
    // 🚨 Returns even though sync work remains in workInProgressRoot
    return null;
  }

So the do/while loop never ends, we just keep detecting that there's sync work to do in the outter function but early returning without doing any work in the inner function.

I think the fix is to complete the TODOs and ensure the same nextLanes are used to flush the sync work.

@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Apr 29, 2023
@rickhanlonii rickhanlonii marked this pull request as draft March 22, 2024 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed React Core Team Opened by a member of the React Core Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants