(
client: any,
route: SlackRoute,
ts: string,
text: string,
maxRetries = 3,
)
| 605 | } |
| 606 | |
| 607 | private async updateWithRetry( |
| 608 | client: any, |
| 609 | route: SlackRoute, |
| 610 | ts: string, |
| 611 | text: string, |
| 612 | maxRetries = 3, |
| 613 | ): Promise<void> { |
| 614 | for (let attempt = 0; attempt <= maxRetries; attempt++) { |
| 615 | try { |
| 616 | await client.chat.update({ |
| 617 | channel: route.channel, |
| 618 | ts, |
| 619 | text: formatSlackMessage(text), |
| 620 | mrkdwn: true, |
| 621 | }); |
| 622 | return; |
| 623 | } catch (err: any) { |
| 624 | const retryAfter = this.getRetryAfterSeconds(err); |
| 625 | if (retryAfter && attempt < maxRetries) { |
| 626 | console.log( |
| 627 | `[Slack] Rate limited while updating, retrying after ${retryAfter}s...`, |
| 628 | ); |
| 629 | await new Promise((resolve) => |
| 630 | setTimeout(resolve, retryAfter * 1000), |
| 631 | ); |
| 632 | continue; |
| 633 | } |
| 634 | throw err; |
| 635 | } |
| 636 | } |
| 637 | } |
| 638 | |
| 639 | private async deleteMessageSafe( |
| 640 | client: any, |
no test coverage detected