question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

WAPI.loadEarlierMessagesTillDate enters infinite loop if the earliest message is posterior to the requested time

See original GitHub issue

Current implementation of loadEarlierMessagesTillDate is

window.WAPI.loadEarlierMessagesTillDate = function (id, lastMessage, done) {
    const found = WAPI.getChat(id);
    x = function () {
        if (found.msgs.models[0].t > lastMessage) {
            found.loadEarlierMsgs().then(x);
        } else {
            done();
        }
    };
    x();
};

This tries to retrieve earlier messages even if the chat doesn’t have any, which may cause an infinite loop. The fix would be something in the lines of:

window.WAPI.loadEarlierMessagesTillDate = function (id, lastMessage, done) {
    const found = WAPI.getChat(id);
    x = function () {
        if (found.msgs.models[0].t > lastMessage && !found.msgs.msgLoadState.noEarlierMsgs) {
            found.loadEarlierMsgs().then(x);
        } else {
            done();
        }
    };
    x();
};

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
smashahcommented, Sep 17, 2019
0reactions
OskJonsdottircommented, Nov 11, 2019

@danielcardeenas Apparently someone fixed this in the original WAPI repo now…

https://github.com/mukulhase/WebWhatsapp-Wrapper/commit/da1dd396e769e3d812a55f929013ab570503d3f3#diff-ab0d21a115b41c44e1ec163f3a78f078R492

Maybe we can update wapi.js in this repo to pull the fix?

Read more comments on GitHub >

github_iconTop Results From Across the Web

R42520 Is In Infinite Loop If Print Message Contains 24 Lines
When Print Message with 24 lines text data is processed by R42520 , the UBE keeps on processing for long time and User...
Read more >
Multicastsocket keeps receiving same message in infinite loop
Basically when this flag is enabled, you will receive messages you send on the multicast socket. So if you also send a message...
Read more >
Infinite loop occurs when using LEAVE trigger and MESSAGE ...
An infinite loop may occur in an application which uses multiple embedded windows. The loop may occur when a LEAVE trigger executes the...
Read more >
Display warning message-Infinite loop - NI Community
During execution, the display enters infinite loop. I want the warning to disappear when pressed "OK" button and ten turn the pump off....
Read more >
The sulla from danielcardeenas - GithubHelp
... enters infinite loop if the earliest message is posterior to the requested time. Current implementation of loadEarlierMessagesTillDate is. window.WAPI.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found