From 010c7d681f7f052fe0f83edf36b941ca2da0d92a Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Sat, 4 Mar 2023 19:12:11 +0800 Subject: [PATCH] Fix ipv6 issue for ping --- server/util-server.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/server/util-server.js b/server/util-server.js index 129e1526..3d4314d6 100644 --- a/server/util-server.js +++ b/server/util-server.js @@ -87,11 +87,8 @@ exports.ping = async (hostname, size = 56) => { return await exports.pingAsync(hostname, false, size); } catch (e) { // If the host cannot be resolved, try again with ipv6 - if (e.message.includes("service not known")) { - return await exports.pingAsync(hostname, true, size); - } else { - throw e; - } + // As node-ping does not report a specific error for this, try again with ipv6 no matter what. + return await exports.pingAsync(hostname, true, size); } };