From 61b984bfa1afe3b50a1b910c114c5855c3a0100a Mon Sep 17 00:00:00 2001 From: Party Wumpus <48649272+PartyWumpus@users.noreply.github.com> Date: Fri, 16 Feb 2024 13:29:24 +0000 Subject: 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 --- frontend/src/wsrouter.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'frontend') diff --git a/frontend/src/wsrouter.ts b/frontend/src/wsrouter.ts index aada457c..b3961125 100644 --- a/frontend/src/wsrouter.ts +++ b/frontend/src/wsrouter.ts @@ -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`); -- cgit v1.2.3