Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Death loop in cleanUnnecessaryInfoFromClient method - logical condition incorrect #12

@dannyboylx

Description

@dannyboylx

Hi Rodrigo, hope all is fine.

I found a logical error leading to death loop in case of low activity on node.js server.

I method cleanUnnecessaryInfoFromClient

--- this loop ---
for (
let i = clientInfo.lastClientRequestList.length - 1;
i >= 0 || remove.length >= 10;
i--
)

jumped sometimes in a situation when i was < 0 so the loop never ended. Server CPU going to 100%, all clients disconnected - only restart helped

--- changing this to ---
for (
let i = clientInfo.lastClientRequestList.length - 1;
i >= 0 && remove.length < 10;
i--
)

solved the problem, so the loop reads max 10 elements and finishes. Not sure if this is optimal solution, but spent almost 2 days diagnosing whole askless TS part and that change permanently solved the problem. I thought first I had issue with some firewalls, resources, but that was a 100% death loop.

Debug mode helped a lot ... debug log before death loop looked like that
LOG

0|chat-server | debug: DisconnectClientsWhoDidntPingTask
0|chat-server | debug: DisconnectClientsWhoDidntPingTask
0|chat-server | [Daniel] Ping check: wss.clients.size = 2
0|chat-server | debug: DisconnectClientsWhoDidntPingTask
0|chat-server | debug: DisconnectClientsWhoDidntPingTask
0|chat-server | debug: DisconnectClientsWhoDidntPingTask
0|chat-server | [Daniel] Ping check: wss.clients.size = 2
0|chat-server | debug: DisconnectClientsWhoDidntPingTask
0|chat-server | debug: DisconnectClientsWhoDidntPingTask
0|chat-server | debug: handleClientRequestInput: Start of removing unnecessary info's of user b589y3mmilD99

Start of removing unnecessary .... was the last line in the log
Hope you can comment on that.

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