Skip to content

Commit 335897e

Browse files
committed
fix: add error handling for speed test failures
1 parent d9f4b69 commit 335897e

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

src/js/app.js

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -110,22 +110,29 @@ const SpeedTest = {
110110
// Generate a random UUID
111111
const sessionID = crypto.randomUUID();
112112

113-
// Randomly choose which test to start first
114-
if (Math.random() < 0.5) {
115-
await this.runNdt7(sessionID);
116-
await this.runMSAK(sessionID);
117-
} else {
118-
await this.runMSAK(sessionID);
119-
await this.runNdt7(sessionID);
120-
}
113+
try {
114+
// Randomly choose which test to start first
115+
if (Math.random() < 0.5) {
116+
await this.runNdt7(sessionID);
117+
await this.runMSAK(sessionID);
118+
} else {
119+
await this.runMSAK(sessionID);
120+
await this.runNdt7(sessionID);
121+
}
121122

122-
this.runPT(sessionID);
123+
this.runPT(sessionID);
123124

124-
this.els.currentPhase.textContent = i18n.t('Complete');
125-
this.els.currentSpeed.textContent = '';
126-
this.measurementComplete = true;
127-
this.testRunning = false;
128-
this.updateUI();
125+
this.els.currentPhase.textContent = i18n.t('Complete');
126+
this.els.currentSpeed.textContent = '';
127+
this.measurementComplete = true;
128+
} catch (err) {
129+
console.error('Speed test failed:', err);
130+
this.els.currentPhase.textContent = i18n.t('Error');
131+
this.els.currentSpeed.textContent = i18n.t('Test failed. Please try again.');
132+
} finally {
133+
this.testRunning = false;
134+
this.updateUI();
135+
}
129136
},
130137

131138
/**

0 commit comments

Comments
 (0)