From 6ccb43b5570ae1d608c1d3442021f29549640a83 Mon Sep 17 00:00:00 2001 From: Jaime Pajuelo Date: Thu, 24 Oct 2024 16:17:10 +0200 Subject: [PATCH] fix: handle ping timeout error after client created --- index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/index.js b/index.js index d5afd4b..7b10092 100755 --- a/index.js +++ b/index.js @@ -1469,6 +1469,11 @@ class NodeClam { } return hasCb ? cb(err, null) : reject(err); }); + client.on('timeout', () => { + if (this.settings.debugMode) console.log(`${this.debugLabel}: Socket/Host connection timed out.`); + client.end(); + reject(new Error('Connection to host has timed out.')); + }); } catch (err) { return hasCb ? cb(err, false) : reject(err); }