Skip to content

Commit dc9e07b

Browse files
committed
feat: add 2 seconds timeout for fetch
1 parent 5234588 commit dc9e07b

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

frontend/testing-view/src/components/settings/SettingsDialog.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,16 @@ export const SettingsDialog = () => {
4242
try {
4343
const res = await fetch(
4444
"https://api.github.com/repos/hyperloop-upv/adj/branches?per_page=100",
45-
{ signal },
45+
{ signal: AbortSignal.any([signal, AbortSignal.timeout(2000)]) },
4646
);
4747
const data = await res.json();
4848
setBranches(data.map((b: { name: string }) => b.name));
4949
} catch (error) {
50-
if (error instanceof Error && error.name !== "AbortError") {
50+
if (
51+
error instanceof Error &&
52+
error.name !== "AbortError" &&
53+
error.name !== "TimeoutError"
54+
) {
5155
console.error("Error loading branches:", error);
5256
}
5357
}

0 commit comments

Comments
 (0)