feat: 增加手动停止错误处理,优化自动重启逻辑
This commit is contained in:
@@ -5062,6 +5062,10 @@ async function runAutoSequenceFromStep(startStep, context = {}) {
|
|||||||
}
|
}
|
||||||
step += 1;
|
step += 1;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
if (isStopError(err)) {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
|
||||||
const restartDecision = await getPostStep6AutoRestartDecision(step, err);
|
const restartDecision = await getPostStep6AutoRestartDecision(step, err);
|
||||||
if (restartDecision.shouldRestart) {
|
if (restartDecision.shouldRestart) {
|
||||||
postStep6RestartCount += 1;
|
postStep6RestartCount += 1;
|
||||||
|
|||||||
@@ -96,6 +96,9 @@ async function getState() {
|
|||||||
mailProvider: '163',
|
mailProvider: '163',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
function isStopError(error) {
|
||||||
|
return (error?.message || String(error || '')) === '流程已被用户停止。';
|
||||||
|
}
|
||||||
function isStepDoneStatus(status) {
|
function isStepDoneStatus(status) {
|
||||||
return status === 'completed' || status === 'manual_completed' || status === 'skipped';
|
return status === 'completed' || status === 'manual_completed' || status === 'skipped';
|
||||||
}
|
}
|
||||||
@@ -195,3 +198,19 @@ test('auto-run stops restarting once add-phone is detected', async () => {
|
|||||||
assert.deepStrictEqual(result.events.steps, [6]);
|
assert.deepStrictEqual(result.events.steps, [6]);
|
||||||
assert.ok(result.events.logs.some(({ message }) => /进入 add-phone/.test(message)));
|
assert.ok(result.events.logs.some(({ message }) => /进入 add-phone/.test(message)));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('auto-run stop errors after step 6 are rethrown immediately instead of restarting', async () => {
|
||||||
|
const harness = createHarness({
|
||||||
|
failureStep: 8,
|
||||||
|
failureBudget: 1,
|
||||||
|
failureMessage: '流程已被用户停止。',
|
||||||
|
authState: { state: 'password_page', url: 'https://auth.openai.com/log-in' },
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await harness.runAndCaptureError();
|
||||||
|
|
||||||
|
assert.equal(result?.error?.message, '流程已被用户停止。');
|
||||||
|
assert.equal(result.events.invalidations.length, 0);
|
||||||
|
assert.deepStrictEqual(result.events.steps, [6, 7, 8]);
|
||||||
|
assert.ok(!result.events.logs.some(({ message }) => /回到步骤 6 重新开始授权流程/.test(message)));
|
||||||
|
});
|
||||||
|
|||||||
+2
-1
@@ -368,7 +368,8 @@
|
|||||||
3. 每轮执行前重置必要运行态
|
3. 每轮执行前重置必要运行态
|
||||||
4. 执行 `runAutoSequenceFromStep`
|
4. 执行 `runAutoSequenceFromStep`
|
||||||
- 步骤 6 内部仍保留登录态恢复的有限重试
|
- 步骤 6 内部仍保留登录态恢复的有限重试
|
||||||
- 一旦进入步骤 6~9,遇到报错且认证流程未进入 `add-phone`,则自动回到步骤 6 无限重开,直到成功、手动停止或命中 `add-phone`
|
- 一旦进入步骤 6~9,遇到普通报错且认证流程未进入 `add-phone`,则自动回到步骤 6 无限重开
|
||||||
|
- 如果是手动停止,则立即退出自动流程,不会再触发“回到步骤 6 重开”
|
||||||
5. 如果失败,根据设置决定:
|
5. 如果失败,根据设置决定:
|
||||||
- 立即停止
|
- 立即停止
|
||||||
- 当前轮重试
|
- 当前轮重试
|
||||||
|
|||||||
Reference in New Issue
Block a user