mirror of
https://github.com/nestriness/nestri.git
synced 2026-08-01 17:34:15 +03:00
fix: Remove unnecessary code in Event Bus
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user