converse.js: Enabling clear_messages_on_reconnection causes missed messages

Describe the bug Using Converse 5.0.5, discovered with https://github.com/conversejs/converse-integration-tests

If you enable clear_messages_on_reconnection, MUC messages sent to you while you are offline/disconnected will go missing. My guess is that the clear_messages_on_reconnection code will clear some messages after the MAM/Smacks/whatever code runs.

Thinking about this, I’m not sure if we still really need this option in the first place.

For example, if you want to prevent the chat history from getting too long or if you want to avoid gaps in the chat history (for example due to MAM not returning all messages since the last cached message).

  • To prevent the chat history from getting too long, it would be better to clear messages on Converse initialization instead of _reconnection. That way there won’t be any interactions with other code.

  • The issue with MAM paging has since been fixed, afaik.

I currently use the following workaround to clear messages on Converse initizalization. Perhaps this can be added as a clear_messages_on_initizalization option?

    var arr = [];

    for (var i = 0; i < localStorage.length; i++){
        if (localStorage.key(i).substring(0,23) == 'local/converse.messages') {
            arr.push(localStorage.key(i));
        }
    }

    for (var i = 0; i < arr.length; i++) {
        localStorage.removeItem(arr[i]);
    }

To Reproduce Run https://github.com/conversejs/converse-integration-tests with clear_messages_on_reconnection: true.

:~/converse-tests$ ./test.py 
We are online! Waiting 1 second before commencing
Testing 25 online messages with disconnect delay 1..
Testing 25 offline messages with disconnect delay 1..
Traceback (most recent call last):
  File "./test.py", line 165, in checkMucMessage
    raise Exception("MUC message %s was not received" %(message))
Exception: MUC message b3df5df8b0e04a37b8f0f849b51ecd20 was not received

:~/converse-tests$ ./test.py 
We are online! Waiting 1 second before commencing
Testing 25 online messages with disconnect delay 0..
Testing 25 offline messages with disconnect delay 1..
Traceback (most recent call last):
  File "./test.py", line 165, in checkMucMessage
    raise Exception("MUC message %s was not received" %(message))
Exception: MUC message a299563b2a704ef7907842c90645dd60 was not received

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 15 (14 by maintainers)

Commits related to this issue

Most upvoted comments

To be clear, this is proper behaviour when entering a new MUC without locally cached history, or when entering a MUC with clear_messages_on_reconnection.

The missing message isn’t permanently inaccessible. You can scroll up to load it. Now, granted… if you can’t scroll because there aren’t enough messages, then you have a problem, but that’s a different issue 😃. To fix that, we need to add a clickable link to load older messages.

But for now, if the page size is large enough, the chat area is scrollable and you can load older messages by scrolling up.