From 36073308ad9f7ec6bb3bd4a766657d62c1d800eb Mon Sep 17 00:00:00 2001 From: awdr74100 Date: Mon, 24 Aug 2026 14:15:22 +0800 Subject: [PATCH] fix(examples/vue/nuxt3): guard hydrate() against a null dehydrated state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit query-core 5.102.1 (#11260) narrowed hydrate()'s second parameter from `unknown` to `Partial` and removed the function's internal runtime guard that used to bail out early on `typeof !== 'object' || === null`. This example's plugin still calls `hydrate(queryClient, vueQueryState.value)` unconditionally, where `vueQueryState` is typed `DehydratedState | null` and stays unset (falsy) whenever the server-side `app:rendered` hook never ran — e.g. routes with `ssr: false`, or purely client-rendered pages. Previously the library's own null check absorbed this; now it throws: TypeError: Cannot read properties of undefined (reading 'mutations') This restores the equivalent guard at the call site, matching the behavior `hydrate()` used to provide internally before 5.102.1. --- examples/vue/nuxt3/plugins/vue-query.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/vue/nuxt3/plugins/vue-query.ts b/examples/vue/nuxt3/plugins/vue-query.ts index 8c0d122db17..10cd291cba7 100644 --- a/examples/vue/nuxt3/plugins/vue-query.ts +++ b/examples/vue/nuxt3/plugins/vue-query.ts @@ -28,9 +28,10 @@ export default defineNuxtPlugin((nuxt) => { }) } - if (import.meta.client) { + if (import.meta.client && vueQueryState.value) { + const dehydratedState = vueQueryState.value nuxt.hooks.hook('app:created', () => { - hydrate(queryClient, vueQueryState.value) + hydrate(queryClient, dehydratedState) }) } })