posva / pinia-colada

🍹 The smart data fetching layer for Pinia
https://pinia-colada.esm.dev/
MIT License
584 stars 7 forks source link

Gc timeout is not triggered in the context of a query declared with the `defineQuery` composable #32

Closed ElisePatrikainen closed 2 weeks ago

ElisePatrikainen commented 2 months ago

It seems that the removeDep function is not called in the context of a query declared with the defineQuery composable. More precisely, the onScopeDispose hook seems not to be called.

Not sure if it is relevant, but I noticed that the scopes are not the same for a query declared with the useQuery composable and the defineQuery composable.

In the useQuery context:

Capture d’écran 2024-04-21 à 19 15 21

And in the defineQuery context:

Capture d’écran 2024-04-21 à 18 56 10

Note: I will provide later the demo of these two cases.

posva commented 2 months ago

Nice catch. The funny part is that I wrote down this initially but forgot to implement it. There are cases where both, onUnmounted and onScopeDispose need to be used to work correctly. For globals like stores, the entry will never be gc collected until the key changes.