diff --git a/.changeset/quick-pens-battle.md b/.changeset/quick-pens-battle.md new file mode 100644 index 0000000000..83a37bb63d --- /dev/null +++ b/.changeset/quick-pens-battle.md @@ -0,0 +1,5 @@ +--- +'@urql/vue': minor +--- + +Remove wrapping request `args` in `reactive` to fix memory leak diff --git a/packages/vue-urql/src/useQuery.ts b/packages/vue-urql/src/useQuery.ts index f298e4bc59..afd714b6af 100644 --- a/packages/vue-urql/src/useQuery.ts +++ b/packages/vue-urql/src/useQuery.ts @@ -1,7 +1,7 @@ /* eslint-disable react-hooks/rules-of-hooks */ import type { Ref, WatchStopHandle } from 'vue'; -import { isRef, reactive, ref, shallowRef, watch, watchEffect } from 'vue'; +import { isRef, ref, shallowRef, watch, watchEffect } from 'vue'; import type { Subscription, Source } from 'wonka'; import { pipe, subscribe, onEnd } from 'wonka'; @@ -241,12 +241,10 @@ export function useQuery( } export function callUseQuery( - _args: UseQueryArgs, + args: UseQueryArgs, client: Ref = useClient(), stops: WatchStopHandle[] = [] ): UseQueryResponse { - const args = reactive(_args) as UseQueryArgs; - const data: Ref = ref(); const stale: Ref = ref(false); const fetching: Ref = ref(false); diff --git a/packages/vue-urql/src/useSubscription.ts b/packages/vue-urql/src/useSubscription.ts index 703700eba6..5da2cfb92d 100644 --- a/packages/vue-urql/src/useSubscription.ts +++ b/packages/vue-urql/src/useSubscription.ts @@ -4,7 +4,7 @@ import type { Source } from 'wonka'; import { pipe, subscribe, onEnd } from 'wonka'; import type { Ref, WatchStopHandle } from 'vue'; -import { isRef, reactive, ref, shallowRef, watch, watchEffect } from 'vue'; +import { isRef, ref, shallowRef, watch, watchEffect } from 'vue'; import type { Client, @@ -239,13 +239,11 @@ export function callUseSubscription< R = T, V extends AnyVariables = AnyVariables, >( - _args: UseSubscriptionArgs, + args: UseSubscriptionArgs, handler?: MaybeRef>, client: Ref = useClient(), stops: WatchStopHandle[] = [] ): UseSubscriptionResponse { - const args = reactive(_args) as UseSubscriptionArgs; - const data: Ref = ref(); const stale: Ref = ref(false); const fetching: Ref = ref(false);