Context
PR #48588 fixes async server cleanup for Feishu, but the same pattern (sync server.close() without awaiting) likely exists in other channel plugins (Telegram, Slack, Discord, etc.). Each plugin implements cleanup differently, leading to recurring port leak and memory leak bugs.
Proposal
Introduce a PluginResourceManager interface that all channel plugins implement:
start(accountId): async resource initialization
stop(accountId): async cleanup with proper await
cleanup(): full teardown with timeout guards
The gateway can then track all plugin resources centrally and ensure proper cleanup before restart.
Follow-up from #48183 / #48588. Credit to @Artyomkun for the architectural suggestion.
Context
PR #48588 fixes async server cleanup for Feishu, but the same pattern (sync server.close() without awaiting) likely exists in other channel plugins (Telegram, Slack, Discord, etc.). Each plugin implements cleanup differently, leading to recurring port leak and memory leak bugs.
Proposal
Introduce a PluginResourceManager interface that all channel plugins implement:
start(accountId): async resource initializationstop(accountId): async cleanup with proper awaitcleanup(): full teardown with timeout guardsThe gateway can then track all plugin resources centrally and ensure proper cleanup before restart.
Follow-up from #48183 / #48588. Credit to @Artyomkun for the architectural suggestion.