()
| 425 | } |
| 426 | |
| 427 | async #create() { |
| 428 | const client = this._self.#clientFactory(); |
| 429 | client._setIdentity(ClientRole.POOL_MEMBER, this._self.#identity.id); |
| 430 | client.on('error', (err: Error) => this.emit('error', err)); |
| 431 | // Track the client as "in use" during connect so it counts toward capacity. |
| 432 | // If we waited to add it until after connect, the pool would think it doesn't |
| 433 | // exist yet and could spin up extra clients when multiple tasks queue up. |
| 434 | const node = this._self.#clientsInUse.push(client); |
| 435 | |
| 436 | try { |
| 437 | await client.connect(); |
| 438 | } catch (err) { |
| 439 | this._self.#clientsInUse.remove(node); |
| 440 | throw err; |
| 441 | } |
| 442 | |
| 443 | this._self.#returnClient(node); |
| 444 | } |
| 445 | |
| 446 | execute<T>(fn: PoolTask<M, F, S, RESP, TYPE_MAPPING, T>) { |
| 447 | return new Promise<Awaited<T>>((resolve, reject) => { |
no test coverage detected