()
| 1000 | |
| 1001 | #initiateSocket(clientId: string): RedisSocket { |
| 1002 | const socketInitiator = async () => { |
| 1003 | const promises = [], |
| 1004 | chainId = Symbol('Socket Initiator'); |
| 1005 | |
| 1006 | const resubscribePromise = this.#queue.resubscribe(chainId); |
| 1007 | resubscribePromise?.catch(error => { |
| 1008 | if (error.message && error.message.startsWith('MOVED')) { |
| 1009 | this.emit('__MOVED', this._self.#queue.removeAllPubSubListeners()); |
| 1010 | } |
| 1011 | }); |
| 1012 | if (resubscribePromise) { |
| 1013 | promises.push(resubscribePromise); |
| 1014 | } |
| 1015 | |
| 1016 | if (this.#monitorCallback) { |
| 1017 | promises.push( |
| 1018 | this.#queue.monitor( |
| 1019 | this.#monitorCallback, |
| 1020 | { |
| 1021 | typeMapping: this._commandOptions?.typeMapping, |
| 1022 | chainId, |
| 1023 | asap: true |
| 1024 | } |
| 1025 | ) |
| 1026 | ); |
| 1027 | } |
| 1028 | |
| 1029 | promises.push(...(await this.#handshake(chainId, true))); |
| 1030 | |
| 1031 | if (promises.length) { |
| 1032 | this.#write(); |
| 1033 | return Promise.all(promises); |
| 1034 | } |
| 1035 | }; |
| 1036 | |
| 1037 | const socket = new RedisSocket( |
| 1038 | socketInitiator, |
nothing calls this directly
no test coverage detected