Fix fetch timeout rolling while in authentication flow. Now each fetch gets a fresh timeout.

This commit is contained in:
2025-12-04 01:35:44 +00:00
parent aa4b1bfd42
commit 4482a601f3
+1 -6
View File
@@ -164,15 +164,10 @@ export async function apiFetch(url, options = {}) {
// Ensure credentials are included for cookie-based auth // Ensure credentials are included for cookie-based auth
fetchOptions.credentials = fetchOptions.credentials || 'include' fetchOptions.credentials = fetchOptions.credentials || 'include'
// Add timeout signal if specified and not already present
if (timeout > 0 && !fetchOptions.signal) {
fetchOptions.signal = AbortSignal.timeout(timeout)
}
while (true) { while (true) {
let response let response
try { try {
response = await fetch(url, fetchOptions) response = await fetch(url, {...fetchOptions, signal: timeout && AbortSignal.timeout(timeout)})
} catch (error) { } catch (error) {
// Handle network errors and timeouts // Handle network errors and timeouts
if (error.name === 'TimeoutError') { if (error.name === 'TimeoutError') {