-
Notifications
You must be signed in to change notification settings - Fork 47.7k
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] Updates "un-committed" when rebasing #17430
Conversation
Adds a failing test case where an update that was committed is later skipped over during a rebase. This should never happen.
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 97ec757:
|
Details of bundled changes.Comparing: 54f6673...97ec757 react-reconciler
react-dom
react-art
react-test-renderer
react-native-renderer
ReactDOM: size: 🔺+0.2%, gzip: 🔺+0.3% Size changes (stable) |
Details of bundled changes.Comparing: 54f6673...97ec757 react-dom
react-native-renderer
react-test-renderer
react-art
react-reconciler
Size changes (experimental) |
4a1e6eb
to
f8adc01
Compare
To enforce that updates that are committed can never be un-committed, even during a rebase, we need to track which updates are part of the rebase. The current implementation doesn't do this properly. It has a hidden assumption that, when rebasing, the next `renderExpirationTime` will represent a later expiration time that the original one. That's usually true, but it's not *always* true: there could be another update at even higher priority. This requires two extra fields on the update queue. I really don't like that the update queue logic has gotten even more complicated. It's tempting to say that we should remove rebasing entirely, and that update queues must always be updated at the same priority. But I'm hesitant to jump to that conclusion — rebasing can be confusing in the edge cases, but it's also convenient. Enforcing single-priority queues would really hurt the ergonomics of useReducer, for example, where multiple values are centralized in a single queue. It especially hurts the ergonomics of classes, where there's only a single queue per class. So it's something to think about, but I don't think "no more rebasing" is an acceptable answer on its own.
b4f4779
to
ac040cc
Compare
newBaseUpdate = prevUpdate; | ||
newBaseState = newState; | ||
newRebaseTime = renderExpirationTime; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooh I think this should be the lower of renderExpirationTime
and the old rebaseTime
. In case there are two rebases in a row. I'll add a new test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would also have to be the further of the two RebaseEnd then, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I don't think this will work. There can be arbitrary numbers of rebases, each with their own ranges and expiration times.
Will need to reevaluate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Highly unsatisfying.
The approach here won't work because of #17430 (comment) Closing in favor of #17483 stack |
To enforce that updates that are committed can never be un-committed, even during a rebase, we need to track which updates are part of the rebase. The current implementation doesn't do this properly. It has a hidden assumption that, when rebasing, the next
renderExpirationTime
will represent a later expiration time that the original one. That's usually true, but it's not always true: there could be another update at even higher priority.This requires two extra fields on the update queue. I really don't like that the update queue logic has gotten even more complicated. It's tempting to say that we should remove rebasing entirely, and that update queues must always be updated at the same priority. But I'm hesitant to jump to that conclusion — rebasing can be confusing in the edge cases, but it's also convenient. Enforcing single-priority queues would really hurt the ergonomics of useReducer, for example, where multiple values are centralized in a single queue. It especially hurts the ergonomics of classes, where there's only a single queue per class.
So it's something to think about, but I don't think "no more rebasing" is an acceptable answer on its own.