/** Only one local operation may wait for the PostgreSQL advisory lock. * Otherwise queued requests could exhaust the pool needed by its current owner. */ export class FlowConfigurationQueue { private tail: Promise = Promise.resolve() run(operation: () => Promise): Promise { const result = this.tail.then(operation) this.tail = result.then(() => undefined, () => undefined) return result } }