Nodes seemingly garbage collected before queries
- Dominant language
- Rust
- Stars
- 19k
- Forks
- 1.9k
- PR merge metrics
- No merged PRs in 30d
Description
When using useLazyLoadQuery, despite a query being in the store the fields no longer are. In this query, the data is not stale. Also, the query does not seem to have been evicted from the cache (useLazyLoadQuery does not suspend), even though the query is not retained. This leads to a response from useLazyLoadQuery that does not match the types, and causes @required's to fail and throw.
Note the edge still seems to show in the store, but the ref it points to is gone (which seems to be why the query things its data is present?)
To reproduce:
Load a page that will throw an error if data is not present in the query (in my case I use `@required(action: THROW)`). Then navigate to other queries to fill up the relay store with ~1000 objects in my code (but not enough to have the maximum number of queries cached or else the whole query will be removed from the store). After returning, since the query is still in the store useLazyLoadQuery does not throw suspense. However, the data required to fulfill the query is no longer in the store (in this case, "weekly_velocity_chart" was evicted).
Reproduced on relay 13 and 14
I could not find documentation describing when individual records would be evicted from the store and not the whole query. I'm wondering if this is some race condition where the query is being evicted and some items have been removed, but not marked as such yet.
Another thing of note with my setup is I do use both react-relay and relay-hooks in various parts of the codebase.
Code:
```
const query = graphql`
query HomeVelocityCardContentQuery {
viewer_company {
weekly_velocity_chart
@required(action: THROW) {
...RelayLineChart_chart
}
}
}
`;
export default function HomeVelocityCardContent({
selectedView,
}: Props): null | JSX.Element {
const data = useLazyLoadQuery(
query,
{ exposureType: selectedView },
{ fetchPolicy: 'store-and-network' },
);
return null;
}
```
This repros throughout our code for different routes, seemingly after a large number of queries causing the store to fill up.
Contributor guide
Assessment
This issue has not been assessed yet.