vuejs / core

🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
https://vuejs.org/
MIT License
47.71k stars 8.34k forks source link

Inconsistent behavior for stop() at a computed ref between 3.4.38 and 3.5.6 #11968

Closed nine-fox closed 2 months ago

nine-fox commented 2 months ago

Vue version

3.5.6

Link to minimal reproduction

https://play.vuejs.org/#eNp9UslOwzAQ/ZWRLxS1SotYDpBWLOIAB0DA0RIK7qQEEtuyx6VSlH9n7NAFCfWWeZveTNyKK2uzZUBxLnKvXGUJPFKwM6mrxhpH0ILDcgSejB2BMo0NhHPooHSmgQO2HkgttTLaE9NBEzqYRs9gcnixpQoG1+7B4BCmM2ilBhZScHrtzJZFHRCGcDSZsLnrE8qgFVVGpxJvWJaoiCOSP0KDIuo6qfNxvwO354GwsXVByBNA/nE0a9tNw67Lx4wk5j0Qcfilqiv1NZXiVzMcSjG70yof94IUugkq9kb8KcoxcYZ+3onLxzsVxUiQ51uV1SL79EbzH0kLxj6NrWp0jzYewUtx3q8euaKuzfd9wsgFHK1x9YHq6x/8068iJsWTQ49uiVJsOCrcAqmnb18ecMXfG7Ix81Czeg/5jN7UIXbsZddBz7n2ji61vUvvqtKLV3+7ItR+vVQsGpVd0kvBb+tmz+rbusfZSfLxG+Arvi3RxUw+4HF2mp2J7gdI4vgA

Steps to reproduce

Click stop_effect button, then error occured: TypeError: runner.effect.stop is not a function.

Please note, the error is not emitted under vue version 3.4.38.

What is expected?

No errors.

The same behavior between these 2 versions.

What is actually happening?

TypeError: runner.effect.stop is not a function.

System Info

playground

Any additional comments?

No response

skirtles-code commented 2 months ago

I can't find any mention of the stop function in the documentation, so I'm unclear whether it is intended to be used in this way. As far as I'm aware, using effectScope is the only documented way to dispose of a computed manually.

10397 deprecated the effect property of ComputedRefImpl, but it seems to have been kept for backwards compatibility:

https://github.com/vuejs/core/pull/10397/files#diff-95734490ac7bb277f876f1c6e635a2718f5f8ac75615d0d72403df5a8903e652R55

That backwards compatibility doesn't include the effect.stop() method, which is needed by the stop function.


Update: After reading the PR description for #10397 a bit more carefully, it looks like a computed can no longer be stopped, even using effectScope. The documentation for effectScope may need updating, as it currently mentions computed.

edison1105 commented 2 months ago

duplicate of https://github.com/vuejs/core/issues/11886