Conversation
Fix verified RED->GREEN. queueWatcher flush-post ordering broken: post watchers spliced by id only at scheduler.ts:183
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What kind of change does this PR introduce? (check at least one)
Does this PR introduce a breaking change? (check one)
The PR fulfills these requirements:
mainbranch for v2.x (or to a previous version branch)fix #xxx[,#xxx], where "xxx" is the issue number)Other information:
When
queueWatcheris called during a flush, the new watcher is spliced into the queue byidonly. A post watcher (flush: 'post') can therefore land before a render watcher with a higher id, which breaks the guarantee that render runs before post callbacks.This PR replaces the id-only comparison in the insertion loop with
sortCompareFn, which orders non-post watchers before post watchers and then by id. That matches the initial queue sort, so post watchers queued mid-flush run after render watchers.Before:
queue[i].id > watcher.idAfter:
sortCompareFn(queue[i], watcher) > 0Verified red to green. The existing unit suite passes (1449 tests, scheduler.spec 8 tests).
Changed file:
src/core/observer/scheduler.ts