fix(runtime-core/scheduler): handle out-of-order invalidateJobs #2982
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In cases where
invalidateJob
is called on a job that has already started (i <= flushIndex
), the remaining contents ofqueue
gets shifted and the job immediately after the current job is skipped.https://github.com/vuejs/vue-next/blob/af9560455d9719a4c5f0d6588d04bfb4c06c8654/packages/runtime-core/src/scheduler.ts#L87-L92
https://github.com/vuejs/vue-next/blob/af9560455d9719a4c5f0d6588d04bfb4c06c8654/packages/runtime-core/src/scheduler.ts#L211-L219
I haven't been able to come up with a good minimal demo of this bug, but hopefully the modifications to the test case can serve as a sufficient example of a scenario that would cause this bug to occur. If the modified test case is run without the fix,
job1
being invalidated would causejob4
to be skipped.For what its worth here's a non-minimal repro:
https://mfro.me/chess/ - built with my fork, includes fix
https://mfro.me/chess-vuerepro/ - built with v3.0.5, no fix
The most noticeable change in behavior is when making 2 consecutive moves on the chess board. The game notation to the right of the board does not update properly for the second or later moves.