Spaces:
Build error
Build error
Added timeout to fetch components
Browse files
frontend/app/components/ui/search/useSearch.tsx
CHANGED
@@ -32,7 +32,9 @@ const useSearch = (): UseSearchResult => {
|
|
32 |
setIsLoading(false);
|
33 |
return;
|
34 |
}
|
35 |
-
const response = await fetch(`${search_api}?query=${query}
|
|
|
|
|
36 |
const data = await response.json();
|
37 |
setSearchResults(data);
|
38 |
} catch (error) {
|
|
|
32 |
setIsLoading(false);
|
33 |
return;
|
34 |
}
|
35 |
+
const response = await fetch(`${search_api}?query=${query}`, {
|
36 |
+
signal: AbortSignal.timeout(10000), // Abort the request if it takes longer than 10 seconds
|
37 |
+
});
|
38 |
const data = await response.json();
|
39 |
setSearchResults(data);
|
40 |
} catch (error) {
|
frontend/app/status/page.tsx
CHANGED
@@ -12,7 +12,9 @@ const StatusPage = () => {
|
|
12 |
const { data, error, isValidating, mutate } = useSWR(healthcheck_api, async (url) => {
|
13 |
try {
|
14 |
// Fetch the data
|
15 |
-
const response = await fetch(url
|
|
|
|
|
16 |
if (!response.ok) {
|
17 |
throw new Error(response.statusText || 'Unknown Error');
|
18 |
}
|
|
|
12 |
const { data, error, isValidating, mutate } = useSWR(healthcheck_api, async (url) => {
|
13 |
try {
|
14 |
// Fetch the data
|
15 |
+
const response = await fetch(url, {
|
16 |
+
signal: AbortSignal.timeout(5000), // Abort the request if it takes longer than 5 seconds
|
17 |
+
});
|
18 |
if (!response.ok) {
|
19 |
throw new Error(response.statusText || 'Unknown Error');
|
20 |
}
|