mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 09:25:06 +03:00
feat(auth): use fetch with timeout for auth calls (#39714)
This commit is contained in:
1 parent
401d6fe892
commit
7df7c4eec3
1 file changed
+15
-1
@@ -175,13 +175,27 @@ async function debuggableNavigatorLock<R>(
|
||||
}
|
||||
}
|
||||
|
||||
// Wrap fetch with 30-second timeout to prevent indefinite hangs
|
||||
const fetchWithTimeout: typeof fetch = async (input, init) => {
|
||||
const timeoutSignal = AbortSignal.timeout(30000); // 30 seconds
|
||||
const existingSignal = init?.signal;
|
||||
const combinedSignal = existingSignal
|
||||
? AbortSignal.any([existingSignal, timeoutSignal])
|
||||
: timeoutSignal;
|
||||
|
||||
return fetch(input, {
|
||||
...init,
|
||||
signal: combinedSignal,
|
||||
});
|
||||
};
|
||||
|
||||
export const gotrueClient = new AuthClient({
|
||||
url: process.env.NEXT_PUBLIC_GOTRUE_URL,
|
||||
storageKey: STORAGE_KEY,
|
||||
detectSessionInUrl: shouldDetectSessionInUrl,
|
||||
debug: debug ? (persistedDebug ? logIndexedDB : true) : false,
|
||||
lock: navigatorLockEnabled ? debuggableNavigatorLock : undefined,
|
||||
|
||||
fetch: fetchWithTimeout,
|
||||
...('localStorage' in globalThis
|
||||
? { storage: globalThis.localStorage, userStorage: globalThis.localStorage }
|
||||
: null),
|
||||
|
||||
Reference in new issue
Block a user