| 406 | } |
| 407 | |
| 408 | async connect() { |
| 409 | if (this._self.#isOpen) return; // TODO: throw error? |
| 410 | this._self.#isOpen = true; |
| 411 | |
| 412 | const promises = []; |
| 413 | while (promises.length < this._self.#options.minimum) { |
| 414 | promises.push(this._self.#create()); |
| 415 | } |
| 416 | |
| 417 | try { |
| 418 | await Promise.all(promises); |
| 419 | } catch (err) { |
| 420 | this.destroy(); |
| 421 | throw err; |
| 422 | } |
| 423 | |
| 424 | return this as unknown as RedisClientPoolType<M, F, S, RESP, TYPE_MAPPING>; |
| 425 | } |
| 426 | |
| 427 | async #create() { |
| 428 | const client = this._self.#clientFactory(); |