*Add safety check on timer

This commit is contained in:
Derrick Hammer 2022-08-18 19:17:56 -04:00
parent b00e598c07
commit cc5c988ce7
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 4 additions and 2 deletions

View File

@ -79,9 +79,11 @@ export default class RpcQuery {
return; return;
} }
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
let timer: NodeJS.Timeout; let timer: any;
socket.on("data", (res: Buffer) => { socket.on("data", (res: Buffer) => {
clearTimeout(timer); if (timer && timer.close) {
clearTimeout(timer as any);
}
socket.end(); socket.end();
const response = unpack(res as any) as RPCResponse; const response = unpack(res as any) as RPCResponse;
if (response && response.error) { if (response && response.error) {