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

Fix cache consistency bug while deleting resources #301

Open
wants to merge 1 commit into
base: v2.2
Choose a base branch
from

Conversation

cesar-tonnoir
Copy link

Context:

Cachememory.removeResource is executed whenever a resource gets deleted.

This method aims to remove the deleted resource from the collections persisted in service cache.

Bug:

Resources that aren't directly related to the deleted resource get removed from the cache as well.

After investigation, we've found out this is caused by the removeResource method that loops over all the available collections, and removes one item every time, whether or not the target resource has been found.

This seems to be caused by the use of the splice method chained with findIndex : findIndex returns -1 when the resource isn't found, and splice removes the last item of the array.

Resolution:

If findIndex returns -1, avoid calling splice

@cesar-tonnoir
Copy link
Author

Hey @pablorsk, what do you think of this one?

I'm struggling to test locally as I can't manage to find a way to build the lib and link it to my project.
Any tip ?

Cheers,
Cesar.

@cesar-tonnoir
Copy link
Author

@pablorsk any news ?
thanks

@veneliniliev
Copy link

@pablorsk please merge this and release update!!!

@veneliniliev
Copy link

@cesar-tonnoir did you find a solution?

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

Successfully merging this pull request may close these issues.

3 participants