fix(ui): seed RTK Query cache after create/update mutations#6217
fix(ui): seed RTK Query cache after create/update mutations#6217jgaul3 wants to merge 2 commits into
Conversation
Signed-off-by: Jon Gaul <jgaul3@gmail.com>
There was a problem hiding this comment.
Verdict: request changes
The onQueryStarted cache-seeding correctly fixes read-after-write for creates and updates, but the delete mutations for flags and segments drop detail-cache invalidation entirely. After deletion, navigating back to the deleted item can serve stale cached data instead of a 404. Add back invalidation for the specific detail tags in deleteFlag and deleteSegment.
ui/src/app/flags/flagsApi.ts
- major (L185): After deleteFlag succeeds, the getFlag cache entry for the deleted flag is never invalidated. If a user navigates back to the flag (browser back, direct URL, or recreated flag with the same key), RTK Query serves the old cached data instead of refetching. Keep invalidatesTags for the specific flag detail tag, or dispatch flagsApi.util.invalidateTags([{ type: 'Flag', id: environmentKey + '/' + namespaceKey + '/' + flagKey }]), alongside the onQueryStarted list update.
ui/src/app/segments/segmentsApi.ts
- major (L176): deleteSegment has the same regression: the getSegment cache for the deleted segment is not cleared, so stale data can persist after deletion. Keep invalidatesTags for the specific segment detail tag, or dispatch segmentsApi.util.invalidateTags([{ type: 'Segment', id: environmentKey + '/' + namespaceKey + '/' + segmentKey }]), alongside the onQueryStarted list update.
🤖 Automated review by the Flipt PR review agent.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## v2 #6217 +/- ##
=======================================
Coverage 62.27% 62.27%
=======================================
Files 145 145
Lines 14815 14815
=======================================
Hits 9226 9226
Misses 4829 4829
Partials 760 760
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@jgaul3 What does your deployment look like? I think the UI is hitting different Flipt instances while you're making changes. |
|
@erka Apologies for the delay, let me check whether we've got some kind of cluster thing going on and get back to you 👍 |
Description
When I use flipt, I find I have to refresh a time or two after making changes for those changes to be reflected in the UI. I'm quite certain this is a read-after-write bug arising from using
invalidatesTagsrather than updating those tags. This PR updates them to generally useonQueryStartedinstead.This applies to creating, updating, and deleting flags and segments, as well as creating branches.
I tested things out locally but since it's partially a network thing that's mostly to confirm that basic processes still work.