fix(session-query): address review round 1

This commit is contained in:
Hypatia May
2026-07-10 17:29:52 +08:00
parent aa1dc0e2c7
commit 18028cad4f
14 changed files with 386 additions and 18 deletions

View File

@@ -106,7 +106,15 @@ export class EventsService {
/** Run listeners concurrently and wait for all of them. */
async parallel(...args: any[]) {
await Promise.all(this.dispatch('emit', args).map(cb => cb(...args)))
const callbacks = this.dispatch('emit', args)
const results = callbacks.map((cb) => {
try {
return Promise.resolve(cb(...args))
} catch (error: unknown) {
return Promise.reject(error)
}
})
await Promise.all(results)
}
/** Run listeners synchronously without waiting for returned promises. */