mirror of
https://github.com/KuekHaoYang/KVideo.git
synced 2026-08-16 09:13:42 +08:00
perf: Reduce retry delays and eliminate unnecessary timeouts for improved responsiveness.
This commit is contained in:
@@ -39,8 +39,8 @@ export async function GET(request: NextRequest) {
|
||||
if (response.status === 503 && attempt < MAX_RETRIES) {
|
||||
console.warn(`⚠ Got 503 on attempt ${attempt}, retrying... (${url})`);
|
||||
lastError = `503 on attempt ${attempt}`;
|
||||
// Wait 500ms before retry
|
||||
await new Promise(resolve => setTimeout(resolve, 500));
|
||||
// Wait 100ms before retry
|
||||
await new Promise(resolve => setTimeout(resolve, 100));
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ export async function GET(request: NextRequest) {
|
||||
lastError = fetchError;
|
||||
if (attempt < MAX_RETRIES) {
|
||||
console.warn(`⚠ Fetch error on attempt ${attempt}, retrying...`, fetchError);
|
||||
await new Promise(resolve => setTimeout(resolve, 500));
|
||||
await new Promise(resolve => setTimeout(resolve, 100));
|
||||
} else {
|
||||
throw fetchError;
|
||||
}
|
||||
|
||||
@@ -33,9 +33,7 @@ export function SearchBox({ onSearch, onClear, initialQuery = '' }: SearchBoxPro
|
||||
setQuery(selectedQuery);
|
||||
onSearch(selectedQuery);
|
||||
// Blur the input after selecting from history
|
||||
setTimeout(() => {
|
||||
inputRef.current?.blur();
|
||||
}, 100);
|
||||
inputRef.current?.blur();
|
||||
});
|
||||
|
||||
// Update query when initialQuery changes
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
const REQUEST_TIMEOUT = 15000;
|
||||
const MAX_RETRIES = 3;
|
||||
const RETRY_DELAY = 1000;
|
||||
const RETRY_DELAY = 200;
|
||||
|
||||
/**
|
||||
* Fetch with timeout support
|
||||
|
||||
@@ -66,7 +66,7 @@ export function useHomePage() {
|
||||
setHasSearched(true);
|
||||
loadCachedResults(cached.results, cached.availableSources);
|
||||
} else {
|
||||
setTimeout(() => handleSearch(urlQuery), 100);
|
||||
handleSearch(urlQuery);
|
||||
}
|
||||
}
|
||||
}, [searchParams, loadFromCache, loadCachedResults]);
|
||||
|
||||
Reference in New Issue
Block a user