fix: only perform cleanup and fire the callback on the first error

This commit is contained in:
2025-06-15 00:18:55 +03:00
parent 27011d4091
commit ef2bebe755
2 changed files with 16 additions and 6 deletions

View File

@ -113,10 +113,9 @@ const ping = (host, port = 19132, cb, timeout = 5000) => {
* @param {Error} err The error that occurred.
*/
const handleError = (err) => {
closeSocket();
if (!didFireError) {
didFireError = true;
closeSocket();
cb(null, err);
}
};