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

use: Don't suspend if there are pending updates #25632

Closed
wants to merge 1 commit into from

Conversation

acdlite
Copy link
Collaborator

@acdlite acdlite commented Nov 3, 2022

Before suspending, check if there are other pending updates that might possibly unblock the suspended component. If so, interrupt the current render and switch to working on that.

This logic was already implemented for the old "throw a Promise" Suspense but has to be replicated for use because it suspends the work loop much earlier.

I'm getting a little anxious about the divergence between the two Suspense patterns. I'm going to look into enabling the new behavior for the old pattern so that we can unify the implementations.

@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Nov 3, 2022
@sizebot
Copy link

sizebot commented Nov 3, 2022

Comparing: 44c4e6f...9ae639e

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.min.js +0.03% 153.75 kB 153.80 kB +0.01% 48.87 kB 48.87 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js +0.03% 155.67 kB 155.72 kB +0.02% 49.49 kB 49.50 kB
facebook-www/ReactDOM-prod.classic.js +0.03% 531.04 kB 531.19 kB +0.02% 94.21 kB 94.23 kB
facebook-www/ReactDOM-prod.modern.js +0.03% 516.29 kB 516.44 kB +0.02% 92.02 kB 92.04 kB
facebook-www/ReactDOMForked-prod.classic.js +0.03% 531.04 kB 531.19 kB +0.02% 94.21 kB 94.23 kB

Significant size changes

Includes any change greater than 0.2%:

(No significant changes)

Generated by 🚫 dangerJS against 9ae639e

Comment on lines +745 to +755
// Finally, React attempts to render the first update again. It also
// finishes successfully, because it was rebased on top of the update that
// hid the suspended component.
// NOTE: These this render happened to not be entangled with the previous
// one. If they had been, this update would have been included in the
// previous render, and there wouldn't be an extra one here. This could
// change if we change our entanglement heurstics. Semantically, it
// shouldn't matter, though in general we try to work on transitions in
// parallel whenever possible. So even though in this particular case, the
// extra render is unnecessary, it's a nice property that it wasn't
// entangled with the other transition.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

filled in some this/that references from my understanding. I hope this makes it easier to grasp what's happening?

Suggested change
// Finally, React attempts to render the first update again. It also
// finishes successfully, because it was rebased on top of the update that
// hid the suspended component.
// NOTE: These this render happened to not be entangled with the previous
// one. If they had been, this update would have been included in the
// previous render, and there wouldn't be an extra one here. This could
// change if we change our entanglement heurstics. Semantically, it
// shouldn't matter, though in general we try to work on transitions in
// parallel whenever possible. So even though in this particular case, the
// extra render is unnecessary, it's a nice property that it wasn't
// entangled with the other transition.
// Finally, React attempts to render the first update again. It also
// finishes successfully, because it was rebased on top of the update that
// hid the suspended component.
// NOTE: The second render happened to not be entangled with the previous
// one. If they had been, the second update would have been included in the
// previous render, and there wouldn't be an extra render here. This could
// change if we change our entanglement heurstics. Semantically, it
// shouldn't matter, though in general we try to work on transitions in
// parallel whenever possible. So even though in this particular case, the
// extra render is unnecessary, it's a nice property that it wasn't
// entangled with the other transition.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thats amazing

Before suspending, check if there are other pending updates that might
possibly unblock the suspended component. If so, interrupt the current
render and switch to working on that.

This logic was already implemented for the old "throw a Promise"
Suspense but has to be replicated for `use` because it suspends the
work loop much earlier.

I'm getting a little anxious about the divergence between the two
Suspense patterns. I'm going to look into enabling the new behavior for
the old pattern so that we can unify the implementations.
@acdlite
Copy link
Collaborator Author

acdlite commented Nov 17, 2022

Closed as part of stack in #25695

@acdlite acdlite closed this Nov 17, 2022
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.

6 participants