Skip to content

Comments

Fix race condition in handleCreateGroup state management#3

Draft
Copilot wants to merge 2 commits intocreate-groupfrom
copilot/sub-pr-1-again
Draft

Fix race condition in handleCreateGroup state management#3
Copilot wants to merge 2 commits intocreate-groupfrom
copilot/sub-pr-1-again

Conversation

Copy link

Copilot AI commented Nov 15, 2025

State was being set before database operations completed in handleCreateGroup. If writes failed, users would see the map view without actually being group members.

Changes

  • Moved state updates (setCurrentGroup, setGroupCode, setCurrentGroupName) to execute after database operations complete
  • State is now only set if both critical writes succeed: group metadata and member addition

Before

setCurrentGroup(finalCode);  // State set early
await database.ref(`groups/${finalCode}/meta`).set({...});
await database.ref(`groups/${finalCode}/members/${user.uid}`).set({...});
// If these fail, user sees map view but isn't in group

After

await database.ref(`groups/${finalCode}/meta`).set({...});
await database.ref(`groups/${finalCode}/members/${user.uid}`).set({...});
// Only set state after critical operations succeed
setCurrentGroup(finalCode);

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: kelliherm <63371331+kelliherm@users.noreply.github.com>
Copilot AI changed the title [WIP] WIP Address feedback on group creation feature implementation Fix race condition in handleCreateGroup state management Nov 15, 2025
Copilot AI requested a review from kelliherm November 15, 2025 18:52
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