-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Unmounting one of multiple components that share a duplicate query deletes RecordSource records #2595
Comments
I've created a reproduction of the issue here: https://github.com/BJTerry/relay-examples
You should see an error in the console like this:
And the entire page crashes. I've created a video of the reproduction here: https://cl.ly/cdab28ee298f |
cc @jstejada |
Thanks for reporting this! As a workaround note that GC can be disabled with |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
If you include two
QueryRenderer
s on a page that have the same query, and then you remove one, it deletes the store data associated with the component becausefetchQueryAndComputeStateFromProps
inReactRelayQueryRenderer.jsx
doesn't properly handle duplicate requests from different components.When
fetchQueryAndComputeStateFromProps
is called the first time, it callsfetch
inReactRelayQueryFetcher
, which then callsexecute
. After the environment executes, eventuallyenvironment.retain
is called inReactRelayQueryFetcher.execute
, which retains the returned data in theRelayMarkSweepStore
(assuming you are using the normal store setup). The second timefetchQueryAndComputeStateFromProps
is called it does not callexecute
because the query matches an in-flight request. Therefore, the data is not retained a second time in theRelayMarkSweepStore
. When you unmount either component, itdispose
s the selector inRelayMarkSweepStore
, which performs agc
, deleting the data for all remaining components.I attempted to create a repro of this, but the glitch site linked in the Issues description is extremely out of date and doesn't support Relay Modern. The above was determined using Relay 1.7.0.
The text was updated successfully, but these errors were encountered: