fix(providers): time out connection tests and guard undefined names

Apply a 15s AbortSignal timeout in fetchWithConnectionProxy when the
caller supplies none, so provider connection tests stop hanging and
exhausting the browser socket pool. Also make matchSearch return false
for falsy provider names instead of crashing the providers page.
This commit is contained in:
Agung Gunawnan
2026-08-28 17:05:55 +07:00
committed by decolua
parent dff648496c
commit df85e16d7a
2 changed files with 11 additions and 3 deletions

View File

@@ -115,9 +115,11 @@ export default function ProvidersPage() {
return () => unregisterSearch();
}, [registerSearch, unregisterSearch]);
const matchSearch = (name) =>
!searchQuery.trim() ||
name.toLowerCase().includes(searchQuery.trim().toLowerCase());
const matchSearch = (name) => {
if (!searchQuery.trim()) return true;
if (!name) return false;
return name.toLowerCase().includes(searchQuery.trim().toLowerCase());
};
const sortByPriority = (entries, authType) =>
[...entries].sort(([ka, a], [kb, b]) => {

View File

@@ -445,6 +445,12 @@ async function testOAuthConnection(connection, effectiveProxy = null) {
}
async function fetchWithConnectionProxy(url, options = {}, effectiveProxy = null) {
// Add a 15-second timeout to prevent connection testing from hanging indefinitely
// and exhausting the browser/Node.js connection pools.
if (!options.signal) {
options.signal = AbortSignal.timeout(15000);
}
// Vercel relay: forward via relay URL
if (effectiveProxy?.vercelRelayUrl) {
const { proxyAwareFetch } = await import("open-sse/utils/proxyFetch.js");