Subscribe on changes!

Watchers no longer fire in the order they're defined from v3.2.38

avatar
Jan 25th 2023

Vue version

v3.2.38-v3.2.45

Link to minimal reproduction

https://sfc.vuejs.org/#eNqVkctOwzAQRX9l8CZBSuI+WKAqrcoKPgCJjTdpMm0Cfsl2UqEo/84kRVUpEqILL2buPb6jmZ49WZt1LbIVy33pGhvAY2jtRuhGWeMC9OBwn8CxCGUNA+ydURAREQktdGm0D6D8AdajLY5eUEoDb8bJ6i66Hy303Wuj0LQhju9hvYFeaBiRrCtkiwQK9mxMtftEwYQeEpjPZrMJnTJjsiZwgY6ZRmImzSEWbO6DYOQe6AH8j1no6mZm6W5nHkJ9ZnJ+Wi8tloqAysoiIFUAeT3f9P20xWHIOVVTt9G2DdClylQo14KRLhhJOT/TLGGnK6WqsNm7N5ruOA0ivgUv2Oo02tijs421YHUI1q84b7X9OGSlUXxLGnetDnSrtDJqu8wW2fKRV40Pl/0MvUp3zhw9OkoULLn4nFOzQ5c61BU6dH+GXXl/BF5pv0LHzIEWy4YvNDjsBg==

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

avatar
Feb 1st 2023

So... Is it bug?

avatar
Feb 1st 2023

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