Skip to content

Commit 4d1fabd

Browse files
committed
fix: add timeout of 3 secs to exam_mode_hosts call
1 parent b38a196 commit 4d1fabd

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/pages/api/active.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,14 @@ function getHostName(ip: string) {
4646
// If this fails, it will return an empty array, so the rest of the code can still run and a clustermap still gets generated
4747
async function getHostsInExamMode() {
4848
try {
49+
const controller = new AbortController();
50+
const timeout = setTimeout(() => controller.abort(), 3000);
51+
4952
// The URL below is only accessible from allowed IP ranges. Ask Codam IT for access if developing locally and you get a 403 error
50-
const request = await fetch("https://clusterdata.codam.nl/api/exam_mode_hosts");
53+
const request = await fetch("https://clusterdata.codam.nl/api/exam_mode_hosts", {
54+
signal: controller.signal,
55+
});
56+
clearTimeout(timeout);
5157
const response = await request.json();
5258
if ("error" in response) {
5359
throw new Error(response["error"]);

0 commit comments

Comments
 (0)