fix(createTokens): invalidate resolve cache on every registry mutation#567
Draft
johnleider wants to merge 2 commits into
Draft
fix(createTokens): invalidate resolve cache on every registry mutation#567johnleider wants to merge 2 commits into
johnleider wants to merge 2 commits into
Conversation
The 7 cache-clearing method wrappers only covered context-level mutators; a ticket's own `unregister()` (bound to the raw registry) bypassed them, leaving stale resolutions in the cache. createTokens now builds its registry with `events: true` and clears the cache from a single subscription to register/unregister/update/reindex/clear events, which covers ticket-level self-removal uniformly. The wrappers are deleted; raw registry methods are exposed via the existing spread with their full inherited signatures.
Contributor
|
✅ Changeset found — this change will be included in the next release. Thanks! |
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.
Group B of the createTokens inspection follow-ups — closes the resolve-cache staleness hole (#2). Targeted at v1.0.x (non-breaking runtime fix; public surface unchanged).
The bug
createTokens memoizes
resolve()and cleared that cache from seven method wrappers (register/upsert/unregister/onboard/offboard/move/clear). But a ticket's ownunregister()is bound to the raw registry method at ticket-creation time, so it bypassed the wrapper entirely:The fix
Build the internal registry with
events: trueand clear the cache from a single subscription to the five mutation events (register:ticket,unregister:ticket,update:ticket,reindex:registry,clear:registry). Event emission covers every mutation path — including ticket-level self-removal — so the whole bug class is closed, not just the one method. This is the same event setuseProxyRegistrysubscribes to.The seven wrappers are deleted; the raw registry methods are exposed through the existing
...registryspread with their full inherited signatures (this also subsumes #564's wrapper-signature alignment — there are no wrappers left to diverge).Verification
pnpm typecheckcleancreateTokens+useTheme/useFeatures/usePermissions/useLocalesuites: 554/554 pass (the consumers all build on createTokens and exercise the shared path)ticket.unregister()scenario above (not committed, per the no-proactive-tests rule) — flagging that feat(group): add new composable #2 has no committed regression test; happy to add one if you want it here.