Skip to content

bug: useSubscriptions re-queries WatermelonDB on every server connection state change, causing unnecessary rooms list flicker #7093

@deepak0x

Description

@deepak0x

app/views/RoomsListView/hooks/useSubscriptions.ts selects the entire server Redux object as a useEffect dependency:

const server = useAppSelector(state => state.server);

}, [isGrouping, sortBy, useRealName, showUnread, showFavorites, groupByType, roles, server]);

Since Redux reducers return a new object reference on every dispatch (even when only connecting or loading fields change), the useEffect fires on every server connection lifecycle transition — not just when the actual server URL changes.

Each spurious fire:

  1. Calls setLoading(true) — rooms list blanks out
  2. Unsubscribes the existing WatermelonDB observable
  3. Creates and subscribes a brand new observable

Steps to Reproduce

  1. Open the app on a slow or unstable network
  2. Watch the rooms list — it briefly flickers/shows a loading spinner multiple times even after rooms have already loaded
  3. Or: toggle airplane mode off → observe rooms list reload multiple times in quick succession

Expected Behavior

The WatermelonDB subscription should only be recreated when the server URL actually changes (i.e. user switches servers). Connection state transitions like connecting: true → false or loading: true → false should not cause the rooms list to re-query.

Actual Behavior

The useEffect fires 4 times during a single reconnection cycle, even though the server URL never changes. Each fire triggers a full WatermelonDB resubscribe and a setLoading(true) flash.

Rocket.Chat Server Version

Not applicable — this is a client-side bug

Rocket.Chat App Version

Latest main branch

Device Name

Any

OS Version

Any (iOS and Android)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions