several bug fixes (by ryogrid #7)

* condition of if statement at line 119 seems to wrong
* Original code can't check size of client.pendingEOSE.get(data[1]) collectly
* Replaced clearInterval to clearTimeout. canceling function for timer which is created by setTimeout is clearTimeout
This commit is contained in:
Ryo Kanbayashi
2023-12-25 23:12:26 +09:00
committed by GitHub
parent c400c3959d
commit 99a076865b

View File

@@ -116,7 +116,7 @@ module.exports = (ws, req) => {
terminate_subs(ws.id);
for (i of ws.reconnectTimeout) {
clearInterval(i);
clearTimeout(i);
// Let the garbage collector do the thing. No need to add ws.reconnectTimeout.delete(i);
}
});
@@ -271,7 +271,7 @@ function newConn(addr, id) {
if (process.env.LOG_ABOUT_RELAYS || log_about_relays) console.log(process.pid, "---", `[${id}]`, `got EOSE from ${relay.url} for ${data[1]}. There are ${client.pendingEOSE.get(data[1])} EOSE received out of ${Array.from(socks).filter(sock => sock.id === id).length} connected relays.`);
if (!cache_relays?.includes(relay.url)) {
if (wait_eose && (client.pendingEOSE.get(data[1]) < (max_eose_score || Array.from(socks).filter(sock => sock.id === id).length))) return;
if (wait_eose && ((client.pendingEOSE.get(data[1]) < max_eose_score) || (client.pendingEOSE.get(data[1]) < Array.from(socks).filter(sock => sock.id === id).length))) return;
if (client.pause_subs.has(data[1])) return client.pause_subs.delete(data[1]);
cancel_EOSETimeout(data[1]);