Got this debugging another error. Filing here for reference. Original code: https://phabricator.intern.facebook.com/P59317705
} else {
          if (
            highestPriorityWork === NoWork ||
            remainingExpirationTime < highestPriorityWork
          ) {
            
            highestPriorityWork = remainingExpirationTime;
            highestPriorityRoot = root;
          }
          if (root === lastScheduledRoot) {
            break;
          }
          previousScheduledRoot = root;
          root = root.nextScheduledRoot;
        }
      }
    }
    
    
    const previousFlushedRoot = nextFlushedRoot;
    if (
      previousFlushedRoot !== null &&
      previousFlushedRoot === highestPriorityRoot &&
      highestPriorityWork === Sync
    ) {
      nestedUpdateCount++;
    } else {
      
      nestedUpdateCount = 0;
    }