-
-
Notifications
You must be signed in to change notification settings - Fork 51
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
Data value vanish after first cached value read access #163
Comments
Okay found out the problem is, if you send ALOT requests simultaneously, the start of an request and the end overwrites the data result. so in my example, we send a user load unneeded often. was kinda 100x in under 1 sec. and same the the response comes in from the first request, there is still requests going out, so this results somehow in overwriting the data value. receives correct data on first response, all other response have an empty value. think also important to mention, the empty value is an array.. so not empty, but on first response it got data in, 2nd the array is empty, cause reference got modified in this time (?!) only an idea, but not sure. this feature mentioned above is still important, cause if you modify i.e an array, cause you have other data flows depending on this modification, only a shallow copy should be stored. EDIT: screenshot here, maybe easier to see whats going on. and maybe also catchable seems the cache is running async to the ongoing response flow?! |
Hey! Thanks for creating this issue. I'm in another city today... If you could create a unit test representing this error it would make it a lot easier! I can work on it tomorrow. |
Hello again! Without code examples, it's hard to reproduce your bug... This is the test: axios-cache-interceptor/test/storage/storages.ts Lines 66 to 91 in 44922f2
|
Instead of just using Can you confirm that this test + fix was your problem? |
@Inoir ? |
I think that it fixed the current problem. For any future problem, you can reopen this issue or create another one. Bye! |
Sorry ill look into this now, haven't had time for it yet. |
Yes this is fixed, works nice! thx alot! |
Setup:
const instance = setupCache(axios.create(), { ttl: 2000 });
so using the internal memory storage. didnt test any other storages.
so first excution of the request is fine.
2nd is also good, after this the data value vanishes somehow out of the storage without trigger any function call on the storage itself (did console logs on find, set, remove => not getting called)
So this may be project specific, casue we are working alot with references in our system. Since references are totaly fine, there should be an mechanism to store and get an shallow copy of the data value.
So for now my current workaround for this is make an own memory storage:
The text was updated successfully, but these errors were encountered: