Skip to content

Queries break collection sync when multiple optimistic updates are queued #645

@obeattie

Description

@obeattie

I've made a repro of an issue I've been seeing in my app where collections with functional where queries can stop syncing when multiple optimistic updates are queued simultaneously. The page needs to be fully reloaded when this happens, so it's a fairly serious issue for me.

Reproduction

https://stackblitz.com/edit/tanstack-db-init-ewe1mn4x Click the "Insert" button to see the issue:

  • The collection without functional where queries continues displaying updates each second. ✓
  • The collection with a functional where query throws errors which you can see in the console, and stops syncing. ✗
Image

Logic

Both share the same logic:

  1. Insert two items simultaneously
  2. Wait for server sync before returning from onInsert
  3. The (simulated) server then sends updates to each item once per second. Only the collection that has a functional where query registered breaks.

I've had difficulty tracing the internal flow here, so any help/advice if I'm doing something wrong in how I'm calling the APId would be appreciated. 🙏

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions