Calling this.$watch
in created
hook sets active effect scope to null which causes subsequent onScopeDispose
and watchEffect
cleanup to fail
#12631
Labels
Vue version
3.5.13
Link to minimal reproduction
https://play.vuejs.org/#eNqdVE1v2zAM/SuEMcAp0MYYtlPmBti6HLbDNqzdad7BkelErSJp+nAzBPnvoyQ7cbOsh94kPvLx8Yn2Lnuv9bTzmM2y0jLDtQOLzut5JflGK+NgBwZb2ENr1AZySs3fHbAbtdE9MC3CJVAFvJJMSevgsXZsDdeBYtLWwuIFgQnquOVLgadgWSQZJIAuDjda1A7pBlA2vJuXol6imJdcau/A/dF4XWVsjexhqbZVBt3VRjUoKBh7V9k8iSiLvrAILC+g6/UGwv74L2WkjaZ0V7wdF8EsqjjKKqigLEbzZZeZs2RNy1fTe6skvcgucmaMCLlA81U7TtZV2QwiErBaCPX4Ocac8Xg5xOMIZ+L3lqaa0eGbQYumI2kHzNVmhS7Bi9svuKXzASQbfBjkGfA7WiV80JjSPnjZkOxRXlT7Ke4Ol6s7u9g6lHYYKggNmfuYT+Z5DF7+b/Sj3DfTt7GukntycdjD40qPljnkxRdYtC0yFzspecuUxo/camWTVUr+kBvlpcOG7ifLX0ncRrYG29qLnlUbpe0MfuaRPv9FdSHMDNL7NpOLQThvYeLW3E5j3iEMUBRwt0bioYeRDEG1EPKSXDTAam/RUgyhZo53CBhnANoajeAULBGkF2JE2CoTC6xfWvztUTpYK/Vgh5Qo5FXsMCGJ13N4fQnpsNuHzzEkka/p8NSoviB8zUrgVKjVJE9SmpSQXwSGylVuZOe5Kj+AfUWsGb3SRMkbgbX0OgpLeOWecCQv8qFj6NnXnOvIEnRU2A8bVo/GfeYnFLbr9Mvd/wUzt8he
Steps to reproduce
Click the playground link. Toggle "visible" and observe the logs. "cleanup" and "scope dispose" will be logged correctly. Now enable "watch". This causes the component to call
this.$watch
first thing in itscreated
hook. Now toggle visible again and notice that "cleanup" and "scope dispose" aren't logged. Also Vue warns about there not being an active effect scope.What is expected?
Showing the component logs "effect".
Destroying the component logs "cleanup", "scope dispose" then "unmounted".
What is actually happening?
Showing the component logs "effect".
Destroying the component logs "unmounted".
System Info
Any additional comments?
My understanding was that is was possible (and allowed?) to call lifecycle hooks in
created
and other composition API hooks. Regardless, it seems odd that callingthis.$watch
would mess up the active effect scope (activeEffectScope
).The text was updated successfully, but these errors were encountered: