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
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
useLoadMissedMessagesreconciles theMessagesstore when theconnectedstate 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 liveroom-messagesandnotify-room/deleteMessage/deleteMessageBulkstream events. Those streams do not replay what was missed while offline.React Query's
refetchOnReconnectdefault does refresh these caches, but only when its online manager fires, which is driven by the browsernavigator.onLineoffline/online events (seeapps/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
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
GET /v1/chat.syncMessages: Performance/Refactoring: Migrate reconnect message synchronization from DDP loadMissedMessages to REST syncMessages with index optimizations #41079ddp-removalTODO that moved reconnect offloadMissedMessages: (ddp-removal): this should move to/v1/chat.syncMessagesso reconnect #41000apps/meteor/client/views/root/hooks/useLoadMissedMessages.tsapps/meteor/client/views/room/contextualBar/Threads/hooks/useThreadMessagesQuery.tsapps/meteor/client/hooks/useInfiniteMessageQueryUpdates.tsrefetchOnReconnectleft at default):apps/meteor/client/lib/queryClient.ts