Skip to content

Commit 92d1727

Browse files
committed
fix: 小程序每步加15秒超时+自动重试,解决automator偶发卡住
1 parent 31c1159 commit 92d1727

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

src/controller/miniprogram_runner.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,21 @@ async function main() {
347347
for (let i = 0; i < steps.length; i++) {
348348
const stepDesc = steps[i].description || steps[i].action;
349349
process.stderr.write(`[PROGRESS] ${i+1}/${steps.length} ${stepDesc}\n`);
350-
const result = await executeStep(steps[i], i + 1);
350+
351+
// 每步加15秒整体超时,超时后重试1次(解决automator偶发卡住)
352+
let result;
353+
try {
354+
result = await withTimeout(executeStep(steps[i], i + 1), 15000, `step${i+1}`);
355+
} catch (e) {
356+
process.stderr.write(`[WARN] 步骤${i+1}超时(15s),重试一次...\n`);
357+
await sleep(1000);
358+
try {
359+
result = await withTimeout(executeStep(steps[i], i + 1), 20000, `step${i+1}_retry`);
360+
} catch (e2) {
361+
result = { step: i + 1, action: steps[i].action, status: 'failed', duration: 0, error: `超时: ${e2.message}`, description: stepDesc };
362+
}
363+
}
364+
351365
results.push(result);
352366
const icon = result.status === 'passed' ? '✅' : '❌';
353367
process.stderr.write(`[STEP] ${icon} #${i+1} ${result.status} ${stepDesc} (${result.duration.toFixed(1)}s)\n`);

0 commit comments

Comments
 (0)