From 3a73e2508b7231b6409c31720af4e06e1a615433 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 13 Feb 2026 23:56:55 +0000 Subject: [PATCH] perf(gateway): skip idle channel shutdown work --- src/gateway/server-channels.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gateway/server-channels.ts b/src/gateway/server-channels.ts index 73a6a11cd7a..1ed2250547f 100644 --- a/src/gateway/server-channels.ts +++ b/src/gateway/server-channels.ts @@ -180,8 +180,12 @@ export function createChannelManager(opts: ChannelManagerOptions): ChannelManage const stopChannel = async (channelId: ChannelId, accountId?: string) => { const plugin = getChannelPlugin(channelId); - const cfg = loadConfig(); const store = getStore(channelId); + // Fast path: nothing running and no explicit plugin shutdown hook to run. + if (!plugin?.gateway?.stopAccount && store.aborts.size === 0 && store.tasks.size === 0) { + return; + } + const cfg = loadConfig(); const knownIds = new Set([ ...store.aborts.keys(), ...store.tasks.keys(),