fix: retry indefinitely on captcha OCR failure with 30s delay
This commit is contained in:
parent
2227233dde
commit
d28e85d821
@ -113,9 +113,11 @@ export class WosService {
|
||||
fid: string,
|
||||
code: string,
|
||||
): Promise<{ success: boolean; message: string; err_code?: number }> {
|
||||
for (let attempt = 1; attempt <= 2; attempt++) {
|
||||
let attempt = 0;
|
||||
while (true) {
|
||||
attempt++;
|
||||
if (attempt > 1) {
|
||||
this.logger.warn(`[${fid}] ${code} 캡차 오인식, 30초 대기 후 재시도`);
|
||||
this.logger.warn(`[${fid}] ${code} 캡차 오인식 (${attempt - 1}회), 30초 대기 후 재시도`);
|
||||
await new Promise((r) => setTimeout(r, 30000));
|
||||
}
|
||||
|
||||
@ -138,15 +140,13 @@ export class WosService {
|
||||
this.logger.log(`[${fid}] ${code} attempt=${attempt} captcha=${captchaCode} → code=${data.code} err=${data.err_code} msg=${data.msg}`);
|
||||
|
||||
if (data.code === 0) return { success: true, message: SUCCESS_MSG };
|
||||
if (data.err_code === 40103 && attempt < 2) continue;
|
||||
if (data.err_code === 40103) continue;
|
||||
return {
|
||||
success: false,
|
||||
message: data.msg || `실패 (${data.err_code})`,
|
||||
err_code: data.err_code,
|
||||
};
|
||||
}
|
||||
|
||||
return { success: false, message: '알 수 없는 오류' };
|
||||
}
|
||||
|
||||
async redeemAll(fid: string) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user