vuejs / apollo

🚀 Apollo/GraphQL integration for VueJS
http://apollo.vuejs.org
MIT License
6.03k stars 523 forks source link

TypeError unwatch is not a function, Vue 3.5.5 regression #1575

Closed deleteme closed 2 months ago

deleteme commented 2 months ago

Describe the bug

The @vue/apollo-option package calls the unwatch function, returned by the Vue instance $watch API.

at SmartQuery.stop (./node_modules/@vue/apollo-option/dist/vue-apollo-option.esm.mjs:574:9)
at SmartQuery.stop (./node_modules/@vue/apollo-option/dist/vue-apollo-option.esm.mjs:743:65)
at SmartQuery.destroy (./node_modules/@vue/apollo-option/dist/vue-apollo-option.esm.mjs:656:12)
at SmartQuery.destroy (./node_modules/@vue/apollo-option/dist/vue-apollo-option.esm.mjs:1035:68)
at DollarApollo.destroy (./node_modules/@vue/apollo-option/dist/vue-apollo-option.esm.mjs:1344:27)
at Proxy.destroy (./node_modules/@vue/apollo-option/dist/vue-apollo-option.esm.mjs:1431:18)
at ./node_modules/@vue/apollo-option/dist/vue-apollo-option.esm.mjs:1487:19
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

In Vue 3.5.0 through 3.5.5, during some SSR scenarios, unwatch is currently not always a function. Instead, it's an object. @vue/apollo-option attempts to call it, and is throwing the TypeError above, resulting in a 500 response.

To Reproduce

I don't have a reproduction available, but if you have an SSR'd apollo option query, you should see the TypeError.

Expected behavior

The TypeError should not be thrown.

Versions vue: 3.5.0 through 3.5.5 vue-apollo: 4.2.0 @apollo/client: 3.10.6

Additional context

I believe this to be a Vue core regression in the 3.5 reactivity refactoring here https://github.com/vuejs/core/blame/d0b513eb463f580e29378e43d112ff6859aa366e/packages/runtime-core/src/apiWatch.ts#L182-L186. I have a vue core fix in the works here and will open a PR soon.

I'm filing this issue to log the error for the benefit of anyone else who experiences this error.

Regarding the @vue/apollo-option unwatch calls in Vue 3.5, they appear to be implemented as no-op functions, and so maybe it's not necessary for @vue/apollo-option to call them anymore.

deleteme commented 2 months ago

Fixed in vue@3.5.6 https://github.com/vuejs/core/blob/main/CHANGELOG.md#356-2024-09-16.