mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-21 17:56:13 +01:00
🔧 fix: Fix rampant pings and rate limiting
- Skips idle connection checks in `getMCPManager` to avoid unnecessary pings. - Introduces a skipOAuthTimeout flag during initial connection to prevent timeouts during server discovery. - Uses a lightweight connection state check instead of ping to avoid rate limits. - Prevents refetch spam and rate limit errors when checking connection status. - Fixes an issue where the server connection was not being disconnected.
This commit is contained in:
parent
1da5365397
commit
10e06f2221
9 changed files with 90 additions and 39 deletions
|
|
@ -59,6 +59,8 @@ export default function MCPPanel() {
|
|||
await Promise.all([
|
||||
queryClient.invalidateQueries([QueryKeys.tools]),
|
||||
queryClient.refetchQueries([QueryKeys.tools]),
|
||||
queryClient.invalidateQueries([QueryKeys.mcpAuthValues]),
|
||||
queryClient.refetchQueries([QueryKeys.mcpAuthValues]),
|
||||
queryClient.invalidateQueries([QueryKeys.mcpConnectionStatus]),
|
||||
queryClient.refetchQueries([QueryKeys.mcpConnectionStatus]),
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -45,13 +45,8 @@ export default function MCPConfigDialog({
|
|||
}: MCPConfigDialogProps) {
|
||||
const localize = useLocalize();
|
||||
|
||||
// Get connection status to determine OAuth requirements with aggressive refresh
|
||||
const { data: statusQuery } = useMCPConnectionStatusQuery({
|
||||
refetchOnMount: true,
|
||||
refetchOnWindowFocus: true,
|
||||
staleTime: 0,
|
||||
cacheTime: 0,
|
||||
});
|
||||
// Get connection status to determine OAuth requirements
|
||||
const { data: statusQuery } = useMCPConnectionStatusQuery();
|
||||
const mcpServerStatuses = statusQuery?.connectionStatus || {};
|
||||
|
||||
// Derive real-time connection status and OAuth requirements
|
||||
|
|
|
|||
|
|
@ -51,9 +51,10 @@ export const useMCPConnectionStatusQuery = <TData = t.TMCPConnectionStatusRespon
|
|||
[QueryKeys.mcpConnectionStatus],
|
||||
() => dataService.getMCPConnectionStatus(),
|
||||
{
|
||||
// refetchOnWindowFocus: false,
|
||||
// refetchOnReconnect: false,
|
||||
// refetchOnMount: true,
|
||||
refetchOnWindowFocus: false, // Stop window focus spam
|
||||
refetchOnReconnect: false, // Stop reconnect spam
|
||||
refetchOnMount: false, // Only fetch when explicitly needed
|
||||
staleTime: 2000, // 2 second cache to prevent excessive calls
|
||||
...config,
|
||||
},
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue