Fix fetch timeout rolling while in authentication flow. Now each fetch gets a fresh timeout.
This commit is contained in:
@@ -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') {
|
||||||
|
|||||||
Reference in New Issue
Block a user