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:
@@ -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]) => {
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user