fix: captcha TOO FREQUENT - retry with 10s wait, increase inter-coupon delay to 5s
This commit is contained in:
parent
9218b0f113
commit
49f77c2a29
@ -116,14 +116,20 @@ export class WosService {
|
|||||||
): Promise<{ success: boolean; message: string; err_code?: number }> {
|
): Promise<{ success: boolean; message: string; err_code?: number }> {
|
||||||
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
||||||
if (attempt > 1) {
|
if (attempt > 1) {
|
||||||
await new Promise((r) => setTimeout(r, 2000));
|
await new Promise((r) => setTimeout(r, 3000));
|
||||||
}
|
}
|
||||||
|
|
||||||
let captchaCode: string;
|
let captchaCode: string;
|
||||||
try {
|
try {
|
||||||
captchaCode = await this.solveCaptcha(fid);
|
captchaCode = await this.solveCaptcha(fid);
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
return { success: false, message: `캡차 오류: ${err.message}` };
|
const msg: string = err.message || '';
|
||||||
|
if (msg.includes('TOO FREQUENT') && attempt < maxRetries) {
|
||||||
|
this.logger.warn(`[${fid}] 캡차 TOO FREQUENT (${attempt}회), 10초 대기 후 재시도`);
|
||||||
|
await new Promise((r) => setTimeout(r, 10000));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
return { success: false, message: `캡차 오류: ${msg}` };
|
||||||
}
|
}
|
||||||
|
|
||||||
const ts = this.now();
|
const ts = this.now();
|
||||||
@ -187,7 +193,7 @@ export class WosService {
|
|||||||
await this.couponLogRepo.save({ fid, coupon_code: coupon.code, result_msg: result.message });
|
await this.couponLogRepo.save({ fid, coupon_code: coupon.code, result_msg: result.message });
|
||||||
results.push({ name: coupon.name, code: coupon.code, status, message: result.message });
|
results.push({ name: coupon.name, code: coupon.code, status, message: result.message });
|
||||||
|
|
||||||
await new Promise((r) => setTimeout(r, 3000));
|
await new Promise((r) => setTimeout(r, 5000));
|
||||||
}
|
}
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user