fix: Remove unnecessary code in Event Bus

This commit is contained in:
Wanjohi
2025-11-05 19:02:36 +03:00
parent d1295aa4ad
commit 138852f87b

View File

@@ -35,27 +35,6 @@ export namespace Bus {
subClient.connect().catch(() => Promise.resolve()),
]);
// global dispatcher for incoming messages
subClient.subscribe("message", (channel: string, message: string) => {
const handlers = subscribers.get(channel);
if (!handlers?.length) return;
try {
const parsed = JSON.parse(message);
for (const h of handlers) {
// call handlers without awaiting so one slow handler doesn't block the dispatcher
try {
const r = h(parsed.detail, parsed) as any;
if (r instanceof Promise)
r.catch((e) => log.error("bus handler error", e));
} catch (e: any) {
log.error("bus handler error", e);
}
}
} catch (e: any) {
log.error("bus: failed to parse message", e);
}
});
return { pubClient, subClient };
} catch (err: any) {
log.error("bus: failed to connect to redis", err);