fix(api): evict API-side public-status cache on visibility change#5126
Open
aprojic wants to merge 1 commit into
Open
fix(api): evict API-side public-status cache on visibility change#5126aprojic wants to merge 1 commit into
aprojic wants to merge 1 commit into
Conversation
The sandbox visibility handler evicted only the proxy-side public-status cache. The API-side preview:public cache (short TTL) was left in place and re-populated the proxy cache on the next request, so a visibility change could take effect later than intended. Evict the API-side entry first, then the proxy-side entry, so any proxy re-query that occurs after eviction re-reads fresh state instead of the stale decision. Adds a regression spec asserting both keys are evicted in that order. Signed-off-by: Ante Projić <anteprojic@gmail.com>
|
Clean fix! Evicting both API-side and proxy-side caches ensures consistent public status. The test verifying both cache keys are deleted is thorough. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
ProxyCacheInvalidationService.invalidatePublicCacheevicted only the proxy-side public-status cache (proxy:sandbox-public:) on a visibility change. The API-side decision cache (preview:public:, short TTL) was left in place and re-populated the proxy cache on the next request, so a public→private change could take effect later than intended.This evicts the API-side entry before the proxy-side entry. The proxy only re-queries the API on a cache miss, and such a miss can only happen after the proxy key is gone — so deleting the API key first means any re-query reads fresh state instead of the stale decision.
Test
Adds
proxy-cache-invalidation.service.spec.ts:PUBLIC_STATUS_UPDATEDVerified the ordering test fails against a proxy-first implementation;
nx run api:testfor the suite passes, prettier + eslint clean.Summary by cubic
Fixes stale public-status cache after sandbox visibility changes by evicting the API-side cache before the proxy cache. Prevents public→private changes from lagging and ensures requests read fresh state.
preview:public:${sandboxId}), then proxy cache (proxy:sandbox-public:${sandboxId}) to avoid repopulating with stale data.Written for commit 0a95dd8. Summary will update on new commits.