From 1adac4f982aa4a39bc4c767cb6a0ac95f53e69ef Mon Sep 17 00:00:00 2001 From: Elijah Date: Sun, 10 Dec 2023 16:03:18 -0500 Subject: [PATCH] switch interval to timeout --- src/VM.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/VM.ts b/src/VM.ts index 3b0412c..9df794f 100644 --- a/src/VM.ts +++ b/src/VM.ts @@ -99,8 +99,8 @@ export default class VM { return; } var msg = msgpack.decode(this.#currentChunk!) as protocol.ProtocolMessage; - if (this.#nopTimeout) clearInterval(this.#nopTimeout); - this.#nopTimeout = setInterval(() => this.#nopTimeoutFunc(), 5000); + if (this.#nopTimeout) clearTimeout(this.#nopTimeout); + this.#nopTimeout = setTimeout(() => this.#nopTimeoutFunc(), 5000); if (!this.isConnectedToVM) { log("INFO", `Got connection to VM at ${this.#id}`); if (this.#messageQueue.size > 0) this.messageQueueLoop(); @@ -120,9 +120,10 @@ export default class VM { Operation: protocol.ProtocolOperation.NOP }); this.#noNop = true; + setTimeout(() => this.#nopTimeoutFunc(), 5000); } else { this.isConnectedToVM = false; - clearInterval(this.#nopTimeout!); + clearTimeout(this.#nopTimeout!); log("INFO", `Connection to VM at ${this.#id} timed out`); } }