facebook / relay

Relay is a JavaScript framework for building data-driven React applications.
https://relay.dev
MIT License
18.36k stars 1.82k forks source link

useLazyLoadQuery won't reload when app code throws error #3575

Open chriserickson opened 3 years ago

chriserickson commented 3 years ago

Context: Given a query that is returning a partial response that, due to a bug in some view code, throws to an error boundary.

We'd like to generically be able to retry all queries (from the error boundary) to see if the backend has recovered.

Currently, the try-again code does the following: 1) calls commitLocalUpdate and calls invalidateStore() on the store. 2) Increments the query keys for EVERY query in the app. 3) Remounts the children

Here is what we are seeing: 1) The component DOES suspend, as expected. I believe this is a result of invalidating the store (otherwise it doesn't suspend, even when incrementing the fetchKey due to store-or-network being the default policy). 2) A new request IS made, as expected. 3) When suspense resolves, the OLD data is returned (with the null values still). <--- THIS IS UNEXPECTED

See reproduction case

stale[bot] commented 2 years ago

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.

tsnobip commented 6 months ago

any news on this? I've bumped into the same kind of error, I wanted to use @required(action: THROW) as a way to detect if a user was logged in, catch when it's not the case in an error boundary to show a login page and refetch the data once the user has logged in. The whole thing was really elegant, but unfortunately, even though the right data is fetched, the UI still reflects the old data before login, so the user has to manually refresh the page, it destroys the whole benefit.