Repository navigation
fix(profile): make profile saves actually revalidate (#581, #586) - #598
Merged
Merged
Conversation
Two independent reasons a profile save left stale data on screen. #581 — invalidateProfileQueries matched nothing. It namespaced its keys under 'scaffald' while the hooks that register those queries did not, so nine of its eleven keys corresponded to no query in the app: invalidator hook ['scaffald','profiles','general'] ['profiles','general'] ['scaffald','profiles','employment'] ['profiles','employment'] ['scaffald','profiles','education-level'] ['profiles','education','level'] ['scaffald','profiles','experience-summary'] ['profiles','experience','summary'] ['scaffald','user-profiles'] ['user-profiles',...] The widget queries the Profile Overview actually renders — ['profiles','widgets', ...] — were not in the list under either spelling, which is why saving a section and navigating to the overview showed pre-save data until staleTime lapsed. Both halves now read from one factory (utils/profile-query-keys.ts), so the two cannot drift apart again. Roots rather than leaves: react-query matches by key prefix, so ['profiles','certifications'] covers tree/top-level/children without the list enumerating them. #586 — the *WithSync hooks merged caller options with `...overrides`, which means a caller's onSuccess replaces the hook's rather than adding to it. ProfileEmploymentLeft passed an empty onSuccess purely as somewhere to hang a comment and silently deleted the only working invalidation on that page. Options are now merged through composeMutationOptions, which chains both handlers with the hook's running first — it owns cache correctness and a caller should not be able to skip it. onMutate is deliberately not chained: react-query threads its return value through as the rollback context and two functions cannot both own that, so the hook's wins. The old test asserted toHaveBeenCalledTimes(11) against a bare mock. Nine of those eleven keys matched nothing and it passed anyway — it never checked that a key corresponded to a real query. It now seeds a real QueryClient with every key the hooks actually register and asserts each one ends up invalidated, so a hook changing its key turns this file red. Co-Authored-By: Claude Opus 5 <[email protected]>
This was referenced Aug 12, 2026
Closed
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.
Closes #581, #586. Part of #594. The epic pairs these because they are two independent reasons the same symptom occurs — you save a profile section and the screen keeps showing pre-save data.
#581 —
invalidateProfileQueriesmatched nothingIt namespaced its keys under
'scaffald'; the hooks that register those queries do not. Nine of eleven keys corresponded to no query in the app:['scaffald','profiles','general']['profiles','general']['scaffald','profiles','employment']['profiles','employment']['scaffald','profiles','education-level']['profiles','education','level']['scaffald','profiles','experience-summary']['profiles','experience','summary']['scaffald','user-profiles']['user-profiles',…]And the widget queries the Profile Overview actually renders —
['profiles','widgets',…]— were absent under either spelling, which is the visible half: edit a section, go to the overview, see the old values untilstaleTimelapses.Both halves now read from one factory,
utils/profile-query-keys.ts. The hooks import their keys from it and the invalidator derives its roots from it, so they cannot drift apart again — a literal is how they drifted in the first place.Roots rather than leaves, deliberately: react-query matches by key prefix, so
['profiles','certifications']coverstree/top-level/childrenwithout the list having to enumerate them and go stale.#586 — caller options replaced the hook's own
The
*WithSynchooks merged with...overrides, so a caller'sonSuccessreplaces the hook's instead of adding to it.ProfileEmploymentLeftpassed an emptyonSuccesspurely as somewhere to hang a comment, and silently deleted the only working invalidation on that page.Options now merge through
composeMutationOptions, which chains both handlers with the hook's running first — it owns cache correctness and a caller's handler should not be able to skip it.onMutateis deliberately not chained: react-query threads its return value through as the rollback context and two functions cannot both own that, so the hook's wins.The helper is typed structurally rather than against
UseMutationOptionsgenerics, so it stays correct across react-query's callback-arity changes (v5 passes(data, variables, context); this version addsonMutateResult).The test that let this through
profile-sync.test.tsassertedtoHaveBeenCalledTimes(11)against a bare mock. Nine of those eleven keys matched nothing and it passed anyway, because it never checked that a key corresponded to anything real.It now seeds a real
QueryClientwith all 21 keys the hooks actually register and asserts every one ends up invalidated — so a hook changing its key turns this file red. Plus a case proving unrelated queries (jobs,communities) are left alone, and one proving a single rejected invalidation does not abort the rest.Verification
profile-syncrewritten,compose-mutation-optionsnew).scf-coretypechecks at 0 errors;pnpm prepushgreen.CI checks will show red without running — Actions billing block, see #375.
🤖 Generated with Claude Code