refactor(server): reuse shared backend in /api/group-status

The handler was allocating a fresh LocalBackend (open DB connections +
repo refresh) on every request and disposing it in finally. createServer
already owns a shared backend for MCP; route /api/group-status through
that instead so concurrent requests no longer multiply DB handles.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
sahalterion 2026-04-17 19:53:08 -07:00
parent f9134f1882
commit f450a3d084

View file

@ -834,14 +834,8 @@ export const createServer = async (port: number, host: string = '127.0.0.1') =>
return;
}
const backend = new LocalBackend();
try {
await backend.init();
const result = await backend.getGroupService().groupStatus({ name: groupName });
res.json(result);
} finally {
await backend.dispose().catch(() => {});
}
const result = await backend.getGroupService().groupStatus({ name: groupName });
res.json(result);
} catch (err: any) {
res.status(500).json({ error: err.message || 'Failed to get group status' });
}