Summary
The Feishu plugin's monitor state cleanup in monitor.state.ts has a potential memory leak. When stopping the monitor, the httpServers are closed but the Map entries are deleted immediately without waiting for the server to fully close.
Steps to Reproduce
- Configure OpenClaw with multiple Feishu accounts
- Start the gateway (Feishu monitor starts)
- Repeatedly restart the gateway or reload Feishu accounts
- Observe memory usage increasing over time
Expected Behavior
When stopFeishuMonitorState() is called, all resources should be properly released:
- WebSocket clients should disconnect
- HTTP servers should close and release ports
- All Map entries should be cleared
Actual Behavior
In monitor.state.ts:145-150:
The issue is that server.close() is asynchronous but the code doesn't wait for the 'close' event before clearing the Map. This can cause:
- Memory leak - server object references retained
- Port binding issues - port not fully released before next start
- Resource leak - incomplete cleanup
Environment
- OpenClaw version: 2026.3.x
- Feishu plugin: All versions
Root Cause Analysis
In monitor.state.ts, the function stopFeishuMonitorState() calls server.close() synchronously but doesn't wait for the callback. This is a classic async cleanup bug.
Proposed Solution
Use the 'close' event to ensure proper cleanup:
Or alternatively, use server.closeAllConnections() for faster cleanup in Node.js.
Labels
bug, memory-leak, feishu
Summary
The Feishu plugin's monitor state cleanup in
monitor.state.tshas a potential memory leak. When stopping the monitor, the httpServers are closed but the Map entries are deleted immediately without waiting for the server to fully close.Steps to Reproduce
Expected Behavior
When
stopFeishuMonitorState()is called, all resources should be properly released:Actual Behavior
In
monitor.state.ts:145-150:The issue is that
server.close()is asynchronous but the code doesn't wait for the 'close' event before clearing the Map. This can cause:Environment
Root Cause Analysis
In
monitor.state.ts, the functionstopFeishuMonitorState()callsserver.close()synchronously but doesn't wait for the callback. This is a classic async cleanup bug.Proposed Solution
Use the 'close' event to ensure proper cleanup:
Or alternatively, use
server.closeAllConnections()for faster cleanup in Node.js.Labels
bug, memory-leak, feishu