Skip to content

Commit 3ef0fd9

Browse files
committed
Fixed a bug in the speedtest.js task
1 parent b599610 commit 3ef0fd9

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

server/tasks/speedtest.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,22 +104,24 @@ module.exports.create = async (type = "auto", retried = false) => {
104104
if (process.env.PREVIEW_MODE === "true") {
105105
await new Promise(resolve => setTimeout(resolve, 5000));
106106
test = {
107-
ping: {latency: Math.floor(Math.random() * 250) + 5},
107+
ping: {latency: Math.floor(Math.random() * 25) + 5},
108108
download: {bytes: Math.floor(Math.random() * 1000000000) + 1000000, elapsed: 10000},
109109
upload: {bytes: Math.floor(Math.random() * 1000000000) + 1000000, elapsed: 10000}
110110
}
111111
} else {
112112
test = await this.run(retried);
113113
}
114114

115-
let {ping, download, upload, time} = await parseData.parseData(mode, test);
115+
let {ping, download, upload, time} = await parseData.parseData(process.env.PREVIEW_MODE === "true" ?
116+
"ookla" : mode, test);
116117

117118
let testResult = await tests.create(ping, download, upload, time, test.serverId, type);
118119
console.log(`Test #${testResult} was executed successfully in ${time}s. 🏓 ${ping}${download}️ ⬆ ${upload}️`);
119120
createRecommendations().then(() => "");
120121
setRunning(false);
121122
sendFinished({ping, download, upload, time}).then(() => "");
122123
} catch (e) {
124+
console.log(e)
123125
if (!retried) return this.create(type, true);
124126
let testResult = await tests.create(-1, -1, -1, null, 0, type, e.message);
125127
await sendError(e.message);

0 commit comments

Comments
 (0)