Watchers no longer fire in the order they're defined from v3.2.38
Vue version
v3.2.38-v3.2.45
Link to minimal reproduction
Steps to reproduce
Observe the console output
What is expected?
The console output being (this is the output for <=v3.2.37):
1st
2nd
3rd
4th
What is actually happening?
The console output being:
1st
4th
3rd
2nd
System Info
System:
OS: Linux 6.1 undefined
CPU: (16) x64 AMD Ryzen 7 6800HS Creator Edition
Memory: 841.05 MB / 27.10 GB
Container: Yes
Shell: 5.9 - /usr/bin/zsh
Binaries:
Node: 16.13.1 - ~/.asdf/installs/nodejs/16.13.1/bin/node
npm: 8.1.2 - ~/.asdf/installs/nodejs/16.13.1/bin/npm
Browsers:
Chromium: 109.0.5414.119
Firefox: 109.0
npmPackages:
vue: ^3.2.45 => 3.2.45
Any additional comments?
No response
I assume this sort here is not stable since a change in 3.2.38 (https://github.com/vuejs/core/commit/78c199d6dbe8931520b75d8bfe0d49366a06922a):
The root cause is: the findInsertionIndex
function returns the same index when job.id is equal, resulting in a misordering of the jobs in the queue.
https://github.com/vuejs/core/blob/957722c4185ea87aabc711f6f8997e528dd3ba1b/packages/runtime-core/src/apiWatch.ts#L362 this resulted in the same jobId