RocketChat / RocketChat/Rocket.Chat
Reconnect sync does not refresh open thread and infinite message lists on DDP-only reconnects
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 46.1k
- Forks
- 13.9k
- Avg merge
- 3d 3h
- Merged PRs (30d)
- 130
Description
Description
Reconnect message synchronization reconciles the main message list but not the thread panel or the infinite message list queries. After a reconnect where a message was edited or deleted while the client was offline, an already open thread or list can keep showing the stale version until that view is reopened.
Where it comes from
useLoadMissedMessages reconciles the Messages store when the connected state goes from false to true. The main room message list reads from that store, so it updates correctly.
The thread panel (useThreadMessagesQuery) and the infinite message lists (useInfiniteMessageQueryUpdates, used by discussions, the threads list and omnichannel history) keep their own React Query caches that are only fed by live room-messages and notify-room/deleteMessage / deleteMessageBulk stream events. Those streams do not replay what was missed while offline.
React Query's refetchOnReconnect default does refresh these caches, but only when its online manager fires, which is driven by the browser navigator.onLine offline/online events (see apps/meteor/client/lib/queryClient.ts, which keeps the default). So a plain network drop is covered.
When it is visible
It shows up on a DDP socket reconnect that does not come with a browser online event, for example a server restart, a proxy blip, or laptop sleep/wake where the socket dropped but the OS still reported online, while a thread or list was open the whole time.
Steps to reproduce
- Open a thread in a room
- Keep the client running but drop only the DDP connection (for example restart the server) so the browser never fires an offline event
- From another user, edit or delete a message inside that thread while the first client is disconnected
- Let the first client reconnect
- The main message list is correct, but the open thread still shows the old content until it is closed and reopened
Suggested direction
Reconcile the affected React Query caches on the same reconnect edge, so threads, discussions, the threads list and omnichannel history are refreshed together rather than each relying on the browser online signal. Worth deciding how broad the invalidation should be to avoid refetching every open list on every reconnect.
References
- Reconnect sync migration to
GET /v1/chat.syncMessages: #41079 - The
ddp-removalTODO that moved reconnect offloadMissedMessages: #41000 - Reconnect sync and store reconciliation:
apps/meteor/client/views/root/hooks/useLoadMissedMessages.ts - Thread panel cache fed only by streams:
apps/meteor/client/views/room/contextualBar/Threads/hooks/useThreadMessagesQuery.ts - Infinite list caches fed only by streams:
apps/meteor/client/hooks/useInfiniteMessageQueryUpdates.ts - Query client defaults (
refetchOnReconnectleft at default):apps/meteor/client/lib/queryClient.ts
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with apps/meteor/client/views/root/hooks/useLoadMissedMessages.ts and trace the reconnect edge into useThreadMessagesQuery.ts and useInfiniteMessageQueryUpdates.ts. Read apps/meteor/client/lib/queryClient.ts to understand the existing reconnect behavior, then reproduce a DDP-only reconnect with an open thread or list. Done means affected open caches refresh after reconnect and no longer show edits or deletions made while disconnected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 56/100