Skip to content

Fix: Update while suspended fails to interrupt#26739

Merged
acdlite merged 2 commits intofacebook:mainfrom
acdlite:fix-update-while-suspended-fails-to-interrupt
Apr 28, 2023
Merged

Fix: Update while suspended fails to interrupt#26739
acdlite merged 2 commits intofacebook:mainfrom
acdlite:fix-update-while-suspended-fails-to-interrupt

Conversation

@acdlite
Copy link
Copy Markdown
Collaborator

@acdlite acdlite commented Apr 28, 2023

This fixes a bug with use where if you update a component that's currently suspended, React will sometimes mistake it for a render phase update.

This happens because we don't reset currentlyRenderingFiber until the suspended is unwound. And with use, that can happen asynchronously, most commonly when the work loop is suspended during a transition.

The fix is to make sure currentlyRenderingFiber is only set when we're in the middle of rendering, which used to be true until use was introduced.

More specifically this means clearing currentlyRenderingFiber when something throws and setting it again when we resume work.

In many cases, this bug will fail "gracefully" because the update is still added to the queue; it's not dropped completely. It's also somewhat rare because it has to be the exact same component that's currently suspended. But it's still a bug. I wrote a regression test that shows a sync update failing to interrupt a suspended component.

Loading
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.

4 participants