fix(session-query): checkpoint review round 3

This commit is contained in:
Hypatia May
2026-07-11 10:19:34 +08:00
parent 18028cad4f
commit 352ea6cf4f
15 changed files with 153 additions and 51 deletions

View File

@@ -106,15 +106,9 @@ export class EventsService {
/** Run listeners concurrently and wait for all of them. */
async parallel(...args: any[]) {
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)
// FIXME(cordis upstream): A synchronous listener throw aborts callback
// enumeration here and starves later parallel listeners. Fix upstream.
await Promise.all(this.dispatch('emit', args).map(cb => cb(...args)))
}
/** Run listeners synchronously without waiting for returned promises. */