Conversation
Discover cacheable methods from server declarations and invalidate client caches when declarations or connection state change. Preserve explicit cache options and reject stale in-flight cache writes.
|
@SaKaNa-Y is attempting to deploy a commit to the NuxtLabs Team on Vercel. A member of the Team first needs to authorize it. |
This branch has not been deployed
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.
Important
Please take a moment to read this. Thank you!
I should include a brief explanation of the problem in my own words in every PR. If that explanation is missing, please @mention me and do not merge this PR until I have added it. You may also leave this PR unaddressed (because this means I have not fulfilled my responsibilities as the author).
If my explanation is unclear or difficult to follow, please ask me to clarify or provide reproduction steps or supporting evidence.
I welcome suggestions and counterarguments, especially questions about anything I may have overlooked. (Your feedback helps me learn and improve. 🙏)
I hold myself to this standard for every PR, regardless of its size.
Summary
Calling a static RPC or a query marked
cacheable: truewithconnectDevframe({ cacheOptions: true })sends every request to the server, including repeated arguments. The client starts with an empty cache function list and never fills it, so the documented option has no effect.Read eligible method names through an authenticated RPC endpoint before using automatic caching. Cache static methods and queries that opt in; keep actions and events running. Preserve explicit function lists and custom serializers, and fall back to normal RPC calls when an older server has no discovery endpoint.
Add a cache invalidation broadcast that hosts can send after changing data. Registration and updates also invalidate the cache and refresh eligibility. Ignore responses that arrive after invalidation when writing cache entries, and clear cached data on trust changes and close. Update the guide, event reference, and API snapshots.
Evidence
1, 1, 2execute static and cacheable query handlers 3 times.After: Both execute 2 times. Uncached queries, actions, and events still execute 3 times.
pnpm lint,pnpm knip,pnpm typecheck, andpnpm buildpass.pnpm test --run: 148 files pass; 1657 tests pass and 13 are skipped.distmodules and confirms the expected handler counts over real WebSocket and SSE connections.Merge Danger
Door: Two-way; this change can be reverted.
Blast Radius: RPC caching. Automatic caching adds one discovery request per cache generation. Invalidation clears all cached methods; hosts must broadcast it after changing data read by cached queries.