feat: 添加邮箱已存在的状态处理,优化注册流程中的错误管理

This commit is contained in:
QLHazyCoder
2026-04-09 10:32:05 +08:00
parent dd720d93f1
commit f44dfd32d6
2 changed files with 35 additions and 2 deletions
+21 -1
View File
@@ -603,6 +603,11 @@ function isRetryableContentScriptTransportError(error) {
return /back\/forward cache|message channel is closed|Receiving end does not exist|port closed before a response was received|A listener indicated an asynchronous response/i.test(message);
}
function isRestartCurrentAttemptError(error) {
const message = String(typeof error === 'string' ? error : error?.message || '');
return /当前邮箱已存在,需要重新开始新一轮/.test(message);
}
function isStepDoneStatus(status) {
return status === 'completed' || status === 'manual_completed' || status === 'skipped';
}
@@ -1297,7 +1302,8 @@ async function autoRunLoop(totalRuns, options = {}) {
const resumeCurrentRun = Number.isInteger(options.resumeCurrentRun) ? options.resumeCurrentRun : 0;
const resumeSuccessfulRuns = Number.isInteger(options.resumeSuccessfulRuns) ? options.resumeSuccessfulRuns : 0;
const resumeAttemptRunsProcessed = Number.isInteger(options.resumeAttemptRunsProcessed) ? options.resumeAttemptRunsProcessed : 0;
const maxAttempts = autoRunSkipFailures ? Math.max(totalRuns * 10, totalRuns + 20) : totalRuns;
let maxAttempts = autoRunSkipFailures ? Math.max(totalRuns * 10, totalRuns + 20) : totalRuns;
const forcedRetryCap = Math.max(totalRuns * 10, totalRuns + 20);
let successfulRuns = Math.max(0, resumeSuccessfulRuns);
let attemptRuns = Math.max(0, resumeAttemptRunsProcessed);
let forceFreshTabsNextRun = false;
@@ -1392,6 +1398,20 @@ async function autoRunLoop(totalRuns, options = {}) {
break;
}
if (isRestartCurrentAttemptError(err)) {
await addLog(`目标 ${targetRun}/${totalRuns} 轮检测到当前邮箱已存在,当前线程已放弃,将重新开始新一轮。`, 'warn');
cancelPendingCommands('当前线程因邮箱已存在而放弃。');
await broadcastStopToContentScripts();
await broadcastAutoRunStatus('retrying', {
currentRun: targetRun,
totalRuns,
attemptRun: attemptRuns,
});
forceFreshTabsNextRun = true;
maxAttempts = Math.max(maxAttempts, Math.min(forcedRetryCap, attemptRuns + 1));
continue;
}
if (!autoRunSkipFailures) {
await addLog(`目标 ${targetRun}/${totalRuns} 轮失败:${err.message}`, 'error');
await broadcastAutoRunStatus('stopped', {