mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-21 02:40:14 +01:00
🔄 fix: Improve MCP Connection Cleanup (#7400)
* chore: linting for mcp related modules * fix: update `isConnected` method to return a Promise and handle connection state asynchronously to properly handle/cleanup disconnected user connections
This commit is contained in:
parent
535e7798b3
commit
fe311df969
4 changed files with 29 additions and 12 deletions
|
|
@ -567,8 +567,14 @@ export class MCPConnection extends EventEmitter {
|
|||
return this.connectionState;
|
||||
}
|
||||
|
||||
public isConnected(): boolean {
|
||||
return this.connectionState === 'connected';
|
||||
public async isConnected(): Promise<boolean> {
|
||||
try {
|
||||
await this.client.ping();
|
||||
return this.connectionState === 'connected';
|
||||
} catch (error) {
|
||||
this.logger?.error(`${this.getLogPrefix()} Ping failed:`, error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public getLastError(): Error | null {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue