fix(registry): invalidate public list cache on registry item writes#4906
Merged
Conversation
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.
Bug:
apps/mesh/src/api/routes/registry/public-mcp-server.tscachesCOLLECTION_REGISTRY_APP_LISTresults in a module-levelpublicListCachewith a 1-hour TTL, keyed by${orgId}:${JSON.stringify(query)}. Nothing ever invalidated this cache.REGISTRY_ITEM_CREATE,REGISTRY_ITEM_UPDATE,REGISTRY_ITEM_DELETE, andREGISTRY_ITEM_BULK_CREATEall write straight to storage and return, with no call to clear the cache.Failure scenario: an org admin deletes a registry item (e.g. a broken or malicious MCP server) or flips
is_publicoff on an item — the unauthenticated public listing endpoint (used to browse/install MCP servers from the store) keeps serving the stale cached page for up to 60 minutes afterward, to any anonymous caller.Fix: export
invalidatePublicRegistryListCache()frompublic-mcp-server.ts(thin wrapper over the cache's already-tested.clear()) and call it from the four mutating tool handlers after a successful write.Verify:
cd apps/mesh && bunx tsc --noEmit(clean). The underlyingclear()primitive is already covered byapps/mesh/src/lib/ttl-lru-cache.test.ts("clear removes all entries"); this change is straight-line wiring with no new branches, so no new unit test was added — full CI covers the rest.Net change: +19/-0, one concern (cache invalidation on write), four call sites.
Summary by cubic
Invalidate the public MCP server list cache after any registry item write to prevent stale results on the public listing. Public changes now appear immediately instead of after up to 60 minutes.
invalidatePublicRegistryListCache()to clear the module-level public list cache.Written for commit 3535f30. Summary will update on new commits.