From cc5c988ce752ef8688dc8f416aebc5f6cee5b180 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Thu, 18 Aug 2022 19:17:56 -0400 Subject: [PATCH] *Add safety check on timer --- src/rpcQuery.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/rpcQuery.ts b/src/rpcQuery.ts index af803b8..1cbce30 100644 --- a/src/rpcQuery.ts +++ b/src/rpcQuery.ts @@ -79,9 +79,11 @@ export default class RpcQuery { return; } return new Promise((resolve, reject) => { - let timer: NodeJS.Timeout; + let timer: any; socket.on("data", (res: Buffer) => { - clearTimeout(timer); + if (timer && timer.close) { + clearTimeout(timer as any); + } socket.end(); const response = unpack(res as any) as RPCResponse; if (response && response.error) {