what if the error handling worked for async event listeners

the anonymous async function is made so the event handlers can each be started in parallel, just in case there's a long running function
This commit is contained in:
Party Wumpus
2024-02-16 13:29:24 +00:00
parent 867ce63f7b
commit 61b984bfa1
+7 -5
View File
@@ -158,11 +158,13 @@ export class WSRouter extends Logger {
case MessageType.EVENT:
if (this.eventListeners.has(data.event)) {
for (const listener of this.eventListeners.get(data.event)!) {
try {
listener(...data.args);
} catch (e) {
this.error(`error in event ${data.event}`, e, listener);
}
(async () => {
try {
await listener(...data.args);
} catch (e) {
this.error(`error in event ${data.event}`, e, listener);
}
})();
}
} else {
this.debug(`event ${data.event} has no listeners`);