Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: memo drops lower pri updates on bail out #18091

Merged
merged 1 commit into from
Feb 21, 2020

Commits on Feb 20, 2020

  1. Bugfix: memo drops lower pri updates on bail out

    Fixes a bug where lower priority updates on a components wrapped with
    `memo` are sometimes left dangling in the queue without ever being
    processed, if they are preceded by a higher priority bailout.
    
    Cause
    -----
    
    The pending update priority field is cleared at the beginning of
    `beginWork`. If there is remaining work at a lower priority level, it's
    expected that it will be accumulated on the work-in-progress fiber
    during the begin phase.
    
    There's an exception where this assumption doesn't hold:
    SimpleMemoComponent contains a bailout that occurs *before* the
    component is evaluated and the update queues are processed, which means
    we don't accumulate the next priority level. When we complete the fiber,
    the work loop is left to believe that there's no remaining work.
    
    Mitigation
    ----------
    
    Since this only happens in a single case, a late bailout in
    SimpleMemoComponent, I've mitigated the bug in that code path by
    restoring the original update priority from the current fiber.
    
    This same case does not apply to MemoComponent, because MemoComponent
    fibers do not contain hooks or update queues; rather, they wrap around
    an inner fiber that may contain those. However, I've added a test case
    for MemoComponent to protect against a possible future regression.
    
    Possible next steps
    -------------------
    
    We should consider moving the update priority assignment in `beginWork`
    out of the common path and into each branch, to avoid similar bugs in
    the future.
    acdlite committed Feb 20, 2020
    Configuration menu
    Copy the full SHA
    0da64c2 View commit details
    Browse the repository at this point in the history