fix: memory leak in SimpleCache causing MCP connection loss (fixes #118)
- Added cleanupTimer property to track setInterval timer - Implemented destroy() method to clear timer and prevent memory leak - Updated MCP server shutdown to call cache.destroy() - Enhanced HTTP server error handling with transport.onerror - Fixed event listener cleanup to prevent accumulation - Added comprehensive test coverage for memory leak prevention This fixes the issue where MCP server would lose connection after several hours due to timer accumulation causing memory exhaustion. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -2538,6 +2538,16 @@ Full documentation is being prepared. For now, use get_node_essentials for confi
|
||||
async shutdown(): Promise<void> {
|
||||
logger.info('Shutting down MCP server...');
|
||||
|
||||
// Clean up cache timers to prevent memory leaks
|
||||
if (this.cache) {
|
||||
try {
|
||||
this.cache.destroy();
|
||||
logger.info('Cache timers cleaned up');
|
||||
} catch (error) {
|
||||
logger.error('Error cleaning up cache:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// Close database connection if it exists
|
||||
if (this.db) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user