* @ignore
(error: Error, ttl: { value?: any }, handlers)
| 731 | * @ignore |
| 732 | */ |
| 733 | handleError(error: Error, ttl: { value?: any }, handlers) { |
| 734 | if (typeof ttl.value === "undefined") { |
| 735 | ttl.value = this.options.maxRedirections; |
| 736 | } else { |
| 737 | ttl.value -= 1; |
| 738 | } |
| 739 | if (ttl.value <= 0) { |
| 740 | handlers.maxRedirections( |
| 741 | new Error("Too many Cluster redirections. Last error: " + error) |
| 742 | ); |
| 743 | return; |
| 744 | } |
| 745 | const errv = error.message.split(" "); |
| 746 | if (errv[0] === "MOVED") { |
| 747 | const timeout = this.options.retryDelayOnMoved; |
| 748 | if (timeout && typeof timeout === "number") { |
| 749 | this.delayQueue.push( |
| 750 | "moved", |
| 751 | handlers.moved.bind(null, errv[1], errv[2]), |
| 752 | { timeout } |
| 753 | ); |
| 754 | } else { |
| 755 | handlers.moved(errv[1], errv[2]); |
| 756 | } |
| 757 | } else if (errv[0] === "ASK") { |
| 758 | handlers.ask(errv[1], errv[2]); |
| 759 | } else if (errv[0] === "TRYAGAIN") { |
| 760 | this.delayQueue.push("tryagain", handlers.tryagain, { |
| 761 | timeout: this.options.retryDelayOnTryAgain, |
| 762 | }); |
| 763 | } else if ( |
| 764 | errv[0] === "CLUSTERDOWN" && |
| 765 | this.options.retryDelayOnClusterDown > 0 |
| 766 | ) { |
| 767 | this.delayQueue.push("clusterdown", handlers.connectionClosed, { |
| 768 | timeout: this.options.retryDelayOnClusterDown, |
| 769 | callback: this.refreshSlotsCache.bind(this), |
| 770 | }); |
| 771 | } else if ( |
| 772 | error.message === CONNECTION_CLOSED_ERROR_MSG && |
| 773 | this.options.retryDelayOnFailover > 0 && |
| 774 | this.status === "ready" |
| 775 | ) { |
| 776 | this.delayQueue.push("failover", handlers.connectionClosed, { |
| 777 | timeout: this.options.retryDelayOnFailover, |
| 778 | callback: this.refreshSlotsCache.bind(this), |
| 779 | }); |
| 780 | } else { |
| 781 | handlers.defaults(); |
| 782 | } |
| 783 | } |
| 784 | |
| 785 | private resetOfflineQueue() { |
| 786 | this.offlineQueue = new Deque(); |
no test coverage detected