Skip to content

Test garbage collection of queries without data#175

Merged
tannerlinsley merged 3 commits intoTanStack:masterfrom
cherniavskii:garbage-collection-test
Feb 29, 2020
Merged

Test garbage collection of queries without data#175
tannerlinsley merged 3 commits intoTanStack:masterfrom
cherniavskii:garbage-collection-test

Conversation

@cherniavskii
Copy link
Contributor

Tests this piece of code:
https://github.com/tannerlinsley/react-query/blob/213df4a4fd87b705789c09d6eb63491e6c7b74c7/src/queryCache.js#L209-L219

Test fails, when cache timeout is set to query.config.cacheTime, i.e.:

 query.scheduleGarbageCollection = () => { 
   query.cacheTimeout = setTimeout( 
     () => { 
       cache.removeQueries(d => d.queryHash === query.queryHash) 
     }, 
-     typeof query.state.data === 'undefined' && 
-       query.state.status !== 'error' 
-       ? 0 
-       : query.config.cacheTime
+      query.config.cacheTime 
   ) 
 } 

@tannerlinsley tannerlinsley merged commit 3724af2 into TanStack:master Feb 29, 2020
@cherniavskii cherniavskii deleted the garbage-collection-test branch February 29, 2020 17:02
@nx-cloud
Copy link

nx-cloud bot commented May 9, 2024

View your CI Pipeline Execution ↗ for commit 387386d.

Command Status Duration Result
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 2s View ↗
nx affected --targets=test:sherif,test:knip,tes... ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2025-05-18 20:01:58 UTC

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

Successfully merging this pull request may close these issues.

2 participants

Comments