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

Fix: Infinite act loop caused by wrong shouldYield #26317

Merged
merged 2 commits into from
Mar 6, 2023

Commits on Mar 5, 2023

  1. Regression test: Bad shouldYield causes act to hang

    Based on a bug report from @bvaughn.
    
    `act` should not consult `shouldYield` when it's performing work,
    because in a unit testing environment, I/O (such as `setTimeout`) is
    likely mocked. So the result of `shouldYield` can't be trusted.
    
    In this regression test, I simulate the bug by mocking `shouldYield` to
    always return `true`. This causes an infinite loop in `act`, because
    it will keep trying to render and React will keep yielding.
    
    I will fix the bug in the next commit by ignoring `shouldYield` whenever
    we're inside an `act` scope.
    acdlite committed Mar 5, 2023
    Configuration menu
    Copy the full SHA
    1a00e1f View commit details
    Browse the repository at this point in the history
  2. Fix: Infinite act loop caused by wrong shouldYield

    Fixes the bug demonstrated by the regression test in the previous
    commit. Refer to previous message for details.
    acdlite committed Mar 5, 2023
    Configuration menu
    Copy the full SHA
    fb31042 View commit details
    Browse the repository at this point in the history