Skip to content

"useFirestoreForProfile" leads to trigger update twice with a preceding async document delete #1176

Open
@bookhahn

Description

@bookhahn

Hi!

I want to delete and update a couple of docs in a redux action, but I have boiled down the problem to the following:

const rrfConfig = {
    userProfile: "users",
    enableClaims: true,
    useFirestoreForProfile: true,
    attachAuthIsReady: true,
};

export const deleteEmployee = async (employee, profile) => {
  const employeeRef = firestore.collections("employees").doc(employee.id);
  const accountRef = firestore.collections("users").doc(profile.uid);
  try {
    await employeeRef.delete();
    await accountRef.update({count: firebase.firestore.FieldValue.increment(1)});
  } catch (error) {
    console.error(error.message);
  }
}

If I run the above code, the user document gets updated twice leading to:
profile.count == 2

If I don't set "useFirestoreForProfile", it works as expected:
user.count == 1

If I don't have another document delete or update before updating the user document, it does work, too. (even with "useFirestoreForProfile" == true)
Even if I am running this from outside via node it works as expected.
That is why I am considering this as a bug.

Note: I am using firebase emulators.

[email protected]
[email protected]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions