fix(identity-service): 限制定时任务每次最多触发10个重试,防止MPC过载

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2025-12-27 09:42:56 -08:00
parent 55bb129477
commit e742a360ec
1 changed files with 11 additions and 0 deletions

View File

@ -43,6 +43,9 @@ const MAX_BACKOFF_MINUTES = 60; // 最大退避时间60分钟
// 每次扫描的最大用户数
const MAX_USERS_PER_SCAN = 100;
// 每次任务最多触发的重试数量(防止 MPC 服务过载)
const MAX_RETRIES_PER_RUN = 10;
export interface KeygenStatusData {
status: 'pending' | 'generating' | 'deriving' | 'completed' | 'failed';
userId: string;
@ -112,6 +115,14 @@ export class WalletRetryTask {
let skippedCount = 0;
for (const userId of incompleteUserIds) {
// 限制每次任务最多触发的重试数量,防止 MPC 服务过载
if (retriedCount >= MAX_RETRIES_PER_RUN) {
this.logger.log(
`[TASK] Reached max retries per run (${MAX_RETRIES_PER_RUN}), stopping`,
);
break;
}
try {
const retried = await this.checkAndRetryUser(userId.value.toString());
if (retried) {