From f5cb701fefa22ab3679d9637e1f2cb337b8d5e5f Mon Sep 17 00:00:00 2001 From: Mathias Wagner Date: Wed, 4 May 2022 22:48:23 +0200 Subject: [PATCH] Fixed an error when creating the speedtest in the absence of an internet connection --- server/tasks/speedtest.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/server/tasks/speedtest.js b/server/tasks/speedtest.js index 2dcd05cc..2b5f1f5b 100644 --- a/server/tasks/speedtest.js +++ b/server/tasks/speedtest.js @@ -20,12 +20,17 @@ module.exports.run = async () => { } module.exports.create = async () => { - let test = await this.run(); - let ping = Math.round(test.ping.latency); - let download = roundSpeed(test.download.bytes, test.download.elapsed); - let upload = roundSpeed(test.upload.bytes, test.upload.elapsed); - let testResult = tests.create(ping, download, upload); - console.log(`Test #${testResult} was executed successfully. 🏓 ${ping} ⬇ ${download}️ ⬆ ${upload}️`); + try { + let test = await this.run(); + let ping = Math.round(test.ping.latency); + let download = roundSpeed(test.download.bytes, test.download.elapsed); + let upload = roundSpeed(test.upload.bytes, test.upload.elapsed); + let testResult = tests.create(ping, download, upload); + console.log(`Test #${testResult} was executed successfully. 🏓 ${ping} ⬇ ${download}️ ⬆ ${upload}️`); + } catch (e) { + let testResult = tests.create(0, 0, 0); + console.log(`Test #${testResult} was not executed successfully. Please try reconnecting to the internet or restarting the software.`); + } } module.exports.removeOld = () => {