Skip to content

Commit e7da8a7

Browse files
committed
fix: reset testRunning flag and re-enable button on test failure
If runNdt7 or runMSAK threw an error (e.g. network failure, server unreachable), the testRunning flag was never reset and startButtonClass remained 'disabled'. This permanently blocked the Start button until the user refreshed the page. Wrap the test runner calls in try/catch/finally: - Success path: unchanged — shows 'Complete' state - Catch: re-enables the button via $scope.$apply so the user can retry - Finally: always resets testRunning = false
1 parent 3b02cd9 commit e7da8a7

File tree

1 file changed

+26
-14
lines changed

1 file changed

+26
-14
lines changed

app/measure/measure.js

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,33 @@ angular.module('Measure.Measure', ['ngRoute'])
4848
const sessionID = uuidv4();
4949

5050
// Randomly choose which test to start first.
51-
if (Math.random() < 0.5) {
52-
await runNdt7(sessionID)
53-
await runMSAK(sessionID);
54-
} else {
55-
await runMSAK(sessionID);
56-
await runNdt7(sessionID);
57-
}
51+
try {
52+
if (Math.random() < 0.5) {
53+
await runNdt7(sessionID);
54+
await runMSAK(sessionID);
55+
} else {
56+
await runMSAK(sessionID);
57+
await runNdt7(sessionID);
58+
}
5859

59-
$scope.$apply(function () {
60-
$scope.currentPhase = gettextCatalog.getString('Complete');
61-
$scope.currentSpeed = '';
62-
$scope.measurementComplete = true;
63-
$scope.startButtonClass = '';
64-
});
65-
testRunning = false;
60+
$scope.$apply(function () {
61+
$scope.currentPhase = gettextCatalog.getString('Complete');
62+
$scope.currentSpeed = '';
63+
$scope.measurementComplete = true;
64+
$scope.startButtonClass = '';
65+
});
66+
} catch (err) {
67+
// If a test fails (e.g. network error), re-enable the button so the
68+
// user can retry without having to refresh the page.
69+
$scope.$apply(function () {
70+
$scope.currentPhase = '';
71+
$scope.currentSpeed = '';
72+
$scope.startButtonClass = '';
73+
});
74+
} finally {
75+
// Always reset the flag, whether the test succeeded or failed.
76+
testRunning = false;
77+
}
6678
}
6779

6880
// Determine the M-Lab project based on a placeholder that is substituted

0 commit comments

Comments
 (0)