Flagsmith / flagsmith-js-client

Javascript Client for Flagsmith. Ship features with confidence using feature flags and remote config. Host yourself or use our hosted version at https://www.flagsmith.com/
https://www.flagsmith.com/
BSD 3-Clause "New" or "Revised" License
60 stars 38 forks source link

Localstorage cache is not being wiped out in some edge cases #211

Closed canyavall closed 8 months ago

canyavall commented 8 months ago

We have seen in production and only in some cases the local-storage was keeping an old version of the flags from Flagsmith.

I could not reproduce it at as maybe it happens one out of 1000 times and as soon as we find the issue we request the user to clear the local-storage.

Current Behavior: The local-storage in very specific cases keeps old data from Flagsmith

Expected behavior: Every time Flagsmith success on request the flags, the local-storage is wiped and replaces the flags itself

I'm very sorry I can not provide a repo to tests it, please tell me if I can help somehow

kyle-ssg commented 8 months ago

As long as cacheFlags is enabled, any response immediately sets the cache, there is no condition around this. Setting storage is async but only within <5ms.

I can't see any possibility other than the following

Looking at the code alone I can't see any possiblity of this so replication steps would be very handy. If any of these jump out to you (especially the first if you're identifying and initialising, i.e. doing 2 immediate network requests to Flagsmith)

kyle-ssg commented 8 months ago

CC @canyavall, if you get any clues / replication on this please let me know, though I can't see how it's possible considering above

kyle-ssg commented 8 months ago

This has been inactive for a while now, please reopen it with the above information if it's still replicable.