Skip to content

Conversation

Copy link

Copilot AI commented Nov 27, 2025

The onSuccess handlers for both mutations called invalidateQueries and then manually called refetch(). Since invalidateQueries already triggers an automatic refetch, the manual calls were redundant and could cause race conditions.

Changes

  • Removed void imageUrls.refetch() from uploadMutation.onSuccess
  • Removed void imageUrls.refetch() from deleteMutation.onSuccess
// Before
onSuccess: () => {
  console.log('File uploaded successfully')
  void queryClient.invalidateQueries({ queryKey: ['ALL_IMAGES'] })
  void imageUrls.refetch()  // Redundant - causes race condition
},

// After
onSuccess: () => {
  console.log('File uploaded successfully')
  void queryClient.invalidateQueries({ queryKey: ['ALL_IMAGES'] })
},

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: adamcameron <2041977+adamcameron@users.noreply.github.com>
Copilot AI changed the title [WIP] Address feedback on file upload functionality for Supabase Remove redundant refetch() calls causing race conditions Nov 27, 2025
Copilot AI requested a review from adamcameron November 27, 2025 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants