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: Synchronous ping during render phase sometimes unwinds the stack, leading to crash #25851

Merged
merged 2 commits into from
Dec 22, 2022

Commits on Dec 8, 2022

  1. Bug: A sync ping in render phase unwinds the stack

    I found this bug when working on a different task.
    
    `pingSuspendedRoot` sometimes calls `prepareFreshStack` to interupt the
    work-in-progress tree and force a restart from the root. The idea is 
    that if the current render is already in a state where it be blocked
    from committing, and there's new data that could unblock it, we might
    as well restart from the beginning.
    
    The problem is that this is only safe to do if `pingSuspendedRoot` is
    called from a non-React task, like an event handler or a microtask.
    While this is usually the case, it's entirely possible for a thenable
    to resolve (i.e. to call `pingSuspendedRoot`) synchronously while the
    render phase is already executing. If that happens, and work loop
    attempts to unwind the stack, it causes the render phase to crash.
    
    This commit adds a regression test that reproduces one of
    these scenarios.
    acdlite committed Dec 8, 2022
    Configuration menu
    Copy the full SHA
    eb55f90 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    9659788 View commit details
    Browse the repository at this point in the history