Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug?] refetch() resolves to undefined after component is unmounted #11752

Open
AlexLMeow opened this issue Apr 4, 2024 · 0 comments
Open

[bug?] refetch() resolves to undefined after component is unmounted #11752

AlexLMeow opened this issue Apr 4, 2024 · 0 comments

Comments

@AlexLMeow
Copy link

AlexLMeow commented Apr 4, 2024

Issue Description

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.

Link to Reproduction

https://codesandbox.io/p/devbox/affectionate-pike-gx8ww7

Reproduction Steps

Click the button in the repro

@apollo/client version

My app is on ~3.4.17
Repro is on 3.9.9

@AlexLMeow 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 AlexLMeow changed the title refetch() resolves to undefined after component is unmounted [bug?] refetch() resolves to undefined after component is unmounted Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant