Skip to content

fix(profile): the employment page's onSuccess override kills the only working invalidation #586

Closed

Description

@thinkclay

ProfileEmploymentLeft passes an onSuccess callback into useEmploymentUpdateMutationWithSync. Because the hook spreads overrides last, that callback replaces the hook's own onSuccess, which is the only working invalidation on that page.

Evidence

packages/scf-core/features/profile/profile-employment-left.tsx:29

const updateMutation = useEmploymentUpdateMutationWithSync({
  onSuccess: () => {
    // Optional: subtle success feedback; errors always shown via mutation onError
  },
})

packages/scf-core/utils/profile-employment-sdk-hooks.ts:118

onSuccess: async () => {
  await queryClient.invalidateQueries({ queryKey: ['profiles', 'employment'] })   // discarded
},
onSettled: async (_d, error) => {
  …
  await invalidateProfileQueries(queryClient)   // no-op, see #581
},
...overrides,   // <- wins

With invalidateProfileQueries also dead, nothing revalidates employment after a save. The UI shows the optimistic cache write for the full 2-minute staleTime, so a server-side coercion or partial write is invisible until the user reloads.

Same override shape at components/EmploymentSection.tsx:49 — worth checking in the same PR.

Acceptance

  • useEmploymentUpdateMutationWithSync composes overrides.onSuccess/onError/onSettled with its own instead of letting them be replaced (call both).
  • Saving an employment card issues a refetch of ['profiles','employment'].
  • A test asserts the internal handler still runs when a caller passes its own.

Activity

  1. added
    bug
    agent-ready
    on Aug 12, 2026
  2. thinkclay commented on Aug 12, 2026

    @thinkclay
    ContributorAuthor

    Part of the profile-building audit rollup: #594

  3. thinkclay commented on Aug 12, 2026

    @thinkclay
    ContributorAuthor

    Fixed in #598 — options now merge through composeMutationOptions, which chains the caller's handler with the hook's rather than replacing it. onMutate stays the hook's, since react-query threads its return value through as the rollback context and two functions cannot both own that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Frontendagent-readybugpriority: mediumtype: frontend

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions