Skip to content

Commit

Permalink
fix: add timeout of 3 secs to exam_mode_hosts call
Browse files Browse the repository at this point in the history
  • Loading branch information
FreekBes committed Nov 30, 2023
1 parent b38a196 commit 4d1fabd
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/pages/api/active.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,14 @@ function getHostName(ip: string) {
// If this fails, it will return an empty array, so the rest of the code can still run and a clustermap still gets generated
async function getHostsInExamMode() {
try {
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), 3000);

// The URL below is only accessible from allowed IP ranges. Ask Codam IT for access if developing locally and you get a 403 error
const request = await fetch("https://clusterdata.codam.nl/api/exam_mode_hosts");
const request = await fetch("https://clusterdata.codam.nl/api/exam_mode_hosts", {
signal: controller.signal,
});
clearTimeout(timeout);
const response = await request.json();
if ("error" in response) {
throw new Error(response["error"]);
Expand Down

0 comments on commit 4d1fabd

Please sign in to comment.