Skip to content

Race condition - useCollection's add #137

@decodeman

Description

@decodeman

Hi @nandorojo Thanks for the work. In basic use, I think I am seeing my add() call mutate my list properly, but then sometimes (maybe 10-20% of the time) the new record is quickly overlayed by an object like the following where exists is false, etc. I tried a basic collection, no query params even, and the firestore db is fine, the data comes back fine if I refresh my NextJS app, the data and page look fine on mutate... but I am assuming there is a race condition here and don't see how to get around it currently. Help appreciated. Thanks!

exists: false
hasPendingWrites: false
id: "lQR2wuCMg36ykf8GKpw0"
__snapshot: undefined

Note: Subsequent adds may work fine, but the problematic one(s) remain so... until the browser refresh is hit.

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