Skip to content
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

Caching "bug" when fetching data #3727

Closed
natrim opened this issue Sep 23, 2019 · 5 comments
Closed

Caching "bug" when fetching data #3727

natrim opened this issue Sep 23, 2019 · 5 comments
Labels

Comments

@natrim
Copy link
Contributor

natrim commented Sep 23, 2019

Just noticed a weird "bug" in ra-core/src/reducer/admin/resource/data.ts

When fetching data they get cached, but when one (or more) of the items is deleted on the backend, the RA cache fails to remove it from existing items.

ie. lets have data:
[{id: 1, name: "one"}, {id:2,name:"two"}]

it gets fetched by GET_LIST and cached
then the data on api is changed, ie. by another app (mobile,db,...)

when you press refresh in RA you get new data without the deleted item
[{id:2,name:"two"}]

but the addRecord method looks on the incoming data and says "look item one is not here, lets just return the old one" and so you have stale data

@Kmaschta
Copy link
Contributor

Thank you for opening this issue. In order to confirm it, we'll have to reproduce it.
As explained in the bug report template, please fork the following CodeSandbox and repeat your issue on it:

https://codesandbox.io/s/github/marmelab/react-admin/tree/master/examples/simple

This is the simplest way to confirm a bug is related to the React Admin codebase.

Moreover, in general, please follow the template for bug report (which version of react admin are you refering to? etc)

@natrim
Copy link
Contributor Author

natrim commented Sep 23, 2019

well you cannot reproduce it by using the simple example codesandbox because changing the fake backend data causes whole app to reload and thus negating the RA caching

noticed it on v3 but v2 seems to use similar code

edit: it would probably help if there was some way to set cache delay in List/Edit/Show and/or some way to force current page fresh load (not counting F5)

@fzaninotto
Copy link
Member

Confirmed, the bug exists in the ids.ts reducer rather than the data.ts reducer.

@sebitoelcheater
Copy link

sebitoelcheater commented Nov 25, 2019

any news respecting this issue? Had the same bug. Is there a way to disable caching?

@fzaninotto
Copy link
Member

Fixed by #4261

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants