From af78a184db411de59e65cc08d523062fed81264d Mon Sep 17 00:00:00 2001 From: Roman Alexander Date: Sun, 8 Oct 2023 16:22:18 -0400 Subject: [PATCH] Fix ping never firing an error when timeout occurs. --- lib/bedrock.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/bedrock.js b/lib/bedrock.js index df6744a..5bf5744 100644 --- a/lib/bedrock.js +++ b/lib/bedrock.js @@ -132,7 +132,7 @@ function ping(host, port = 19132, cb, timeout = 5000) { // Close the socket and clear the timeout task // This is a general cleanup for success conditions closeSocket(); - cb(null, clientData); + cb(clientData, null); break; } @@ -160,9 +160,9 @@ export function pingBedrock(host, options = {}) { const { port = 19132, timeout = 5000 } = options; - return new Promise((resilve, reject) => { - ping(host, port, (err, res) => { - err ? reject(err) : resilve(res); + return new Promise((resolve, reject) => { + ping(host, port, (res, err) => { + err ? reject(err) : resolve(res); }, timeout); }); }