diff --git a/src/Instance.ts b/src/Instance.ts index 7cd789d29..3882b634a 100644 --- a/src/Instance.ts +++ b/src/Instance.ts @@ -298,23 +298,25 @@ export default class Instance { } async processEvent(event: IBMiEvent) { - const eventSubscribers = this.getSubscribers(event) + const eventSubscribers = this.getSubscribers(event); console.time(event); - for (const [identity, callable] of eventSubscribers.entries()) { - try { - console.time(identity); - await callable.func(); - console.timeEnd(identity); - } - catch (error) { - console.error(`${event} event function ${identity} failed`, error); - } - finally { - if (callable.transient) { - eventSubscribers.delete(identity); + await Promise.allSettled( + Array.from(eventSubscribers.entries()).map(async ([identity, callable]) => { + try { + console.time(identity); + await callable.func(); + console.timeEnd(identity); } - } - } + catch (error) { + console.error(`${event} event function ${identity} failed`, error); + } + finally { + if (callable.transient) { + eventSubscribers.delete(identity); + } + } + }) + ); console.timeEnd(event); } } \ No newline at end of file