Skip to content

bug: rejoinRooms silently drops missed messages beyond 100 #16

Description

@Aaromalpm

Problem

In src/reconnect.js, missed messages are fetched with a hardcoded page 1, limit 100:

const { messages } = getRoomMessages(roomId, 1, 100)
missedMessages[roomId] = messages.filter(m => new Date(m.createdAt) > since)

If more than 100 messages were sent to a room while the user was disconnected, only the first 100 are checked. Messages beyond that are silently lost.

Expected behavior

rejoinRooms() should return all messages sent since the given timestamp, regardless of count.

Fix

Paginate through all messages until no more remain past the since timestamp, or fetch all messages for the room and filter:

const allMessages = getRoomMessages(roomId, 1, Infinity) // or paginate
missedMessages[roomId] = allMessages.messages.filter(m => new Date(m.createdAt) > since)

A cleaner fix would be to add an internal getMessagesSince(roomId, since) function to messages.js that does a single filtered pass over the in-memory array.

Files

  • src/reconnect.js — line 37
  • src/messages.js — candidate location for a getMessagesSince() helper

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions