You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Async functions might end up calling refetch()after the component containing useQuery is unmounted. When this happens, await refetch() resolves to undefined, breaking any downstream code that works on the refetch result.
The typescript return value is Promise<ApolloQueryResult<TData>> so undefined is unexpected.
Seems to only occur when ApolloClient is set up with assumeImmutableResults: true.
I also have some evidence that this can occur even when the component is still mounted, but I couldn't pin down the exact scenario. Let me know if you find another trigger for this bug so i can go back and validate my application behavior accordingly.
The text was updated successfully, but these errors were encountered:
AlexLMeow
changed the title
refetch() resolves to undefined after component is unmounted when assumeImmutableResults is true
refetch() resolves to undefined after component is unmounted
Apr 4, 2024
AlexLMeow
changed the title
refetch() resolves to undefined after component is unmounted
[bug?] refetch() resolves to undefined after component is unmounted
Apr 4, 2024
Issue Description
Async functions might end up calling
refetch()
after the component containinguseQuery
is unmounted. When this happens,await refetch()
resolves toundefined
, breaking any downstream code that works on the refetch result.The typescript return value is
Promise<ApolloQueryResult<TData>>
soundefined
is unexpected.Seems to only occur when ApolloClient is set up with
assumeImmutableResults: true
.I also have some evidence that this can occur even when the component is still mounted, but I couldn't pin down the exact scenario. Let me know if you find another trigger for this bug so i can go back and validate my application behavior accordingly.
Link to Reproduction
https://codesandbox.io/p/devbox/affectionate-pike-gx8ww7
Reproduction Steps
Click the button in the repro
@apollo/client
versionMy app is on ~3.4.17
Repro is on 3.9.9
The text was updated successfully, but these errors were encountered: