| 60 | } |
| 61 | |
| 62 | private async runLoop() { |
| 63 | this.polling = true; |
| 64 | |
| 65 | let failureCount = 0; |
| 66 | |
| 67 | while (this.polling) { |
| 68 | try { |
| 69 | await this.pollIteration(); |
| 70 | if (failureCount > 0) { |
| 71 | log(`Poll iteration recovered after ${failureCount} failures`); |
| 72 | failureCount = 0; |
| 73 | } |
| 74 | } catch (e) { |
| 75 | log("Failed poll iteration", { |
| 76 | failureCount, |
| 77 | error: e, |
| 78 | }); |
| 79 | |
| 80 | failureCount++; |
| 81 | } |
| 82 | |
| 83 | await new Promise((resolve) => |
| 84 | setTimeout(resolve, this.retryAfter * 1000), |
| 85 | ); |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | private async pollIteration() { |
| 90 | if (!this.clusterId) { |