Garbage collection is not scheduled when Query Operation Observable publishes new data
- Dominant language
- Rust
- Stars
- 19k
- Forks
- 1.9k
- PR merge metrics
- No merged PRs in 30d
Description
I am experimenting with live queries and I noticed that the cache is constantly growing in size when [returning an Observable from fetchQuery](https://github.com/n1ru4l/graphql-live-queries/blob/master/packages/example/client/src/createRelayEnvironment.tsx) that publishes new values over time (as the server sends new data).
The cause of this is a list to which items are added and removed. The removed items are still in the cache after they are no longer referenced by the active query. (Example query: https://github.com/n1ru4l/graphql-live-queries/blob/ffe68287d55664b294e646a076f6bef68165a782/packages/example/client/src/ChatApplication.tsx#L9)
However, when unmounting the QueryRenderer that once referenced those objects the cache is cleared.
I would expect the cache/store to get rid of those elements as soon as the elements are no longer referenced by the field that returns the list.
Is this something that is expected to be implemented in user-land or could this be something that is accepted to be part of the relay core?
**Edit:** When I manually invoke the `__gc()` or `_scheduleGC` method on the RelayStore the stale records are deleted while the query is still referenced.
Contributor guide
Assessment
This issue has not been assessed yet.