(trigger = 'alarm', options = {})
| 3953 | let autoRunTimerLaunching = false; |
| 3954 | |
| 3955 | async function launchAutoRunTimerPlan(trigger = 'alarm', options = {}) { |
| 3956 | const { expectedKinds = [] } = options; |
| 3957 | if (autoRunTimerLaunching) { |
| 3958 | return false; |
| 3959 | } |
| 3960 | |
| 3961 | autoRunTimerLaunching = true; |
| 3962 | try { |
| 3963 | const state = await getState(); |
| 3964 | const plan = getPendingAutoRunTimerPlan(state); |
| 3965 | if (!plan) { |
| 3966 | return false; |
| 3967 | } |
| 3968 | if (expectedKinds.length && !expectedKinds.includes(plan.kind)) { |
| 3969 | return false; |
| 3970 | } |
| 3971 | if (autoRunActive) { |
| 3972 | return false; |
| 3973 | } |
| 3974 | |
| 3975 | const resumeOptions = getAutoRunTimerResumeOptions(plan); |
| 3976 | if (!resumeOptions) { |
| 3977 | await clearAutoRunTimerAlarm(); |
| 3978 | await broadcastAutoRunStatus('idle', { |
| 3979 | currentRun: 0, |
| 3980 | totalRuns: 1, |
| 3981 | attemptRun: 0, |
| 3982 | }, { |
| 3983 | autoRunRoundSummaries: [], |
| 3984 | autoRunTimerPlan: null, |
| 3985 | scheduledAutoRunPlan: null, |
| 3986 | }); |
| 3987 | return false; |
| 3988 | } |
| 3989 | |
| 3990 | await clearAutoRunTimerAlarm(); |
| 3991 | autoRunCurrentRun = resumeOptions.statusPayload.currentRun; |
| 3992 | autoRunTotalRuns = plan.totalRuns; |
| 3993 | autoRunAttemptRun = resumeOptions.statusPayload.attemptRun; |
| 3994 | if (plan.kind === AUTO_RUN_TIMER_KIND_SCHEDULED_START && trigger !== 'manual' && state.autoRunDelayEnabled) { |
| 3995 | await setAutoRunDelayEnabledState(false); |
| 3996 | } |
| 3997 | await broadcastAutoRunStatus( |
| 3998 | 'running', |
| 3999 | resumeOptions.statusPayload, |
| 4000 | { |
| 4001 | autoRunSkipFailures: plan.autoRunSkipFailures, |
| 4002 | autoRunRoundSummaries: serializeAutoRunRoundSummaries(plan.totalRuns, plan.roundSummaries), |
| 4003 | autoRunTimerPlan: null, |
| 4004 | scheduledAutoRunPlan: null, |
| 4005 | } |
| 4006 | ); |
| 4007 | |
| 4008 | clearStopRequest(); |
| 4009 | let logMessage = '倒计时结束,自动运行开始执行。'; |
| 4010 | if (plan.kind === AUTO_RUN_TIMER_KIND_BETWEEN_ROUNDS) { |
| 4011 | logMessage = trigger === 'manual' |
| 4012 | ? '已手动跳过线程间隔,自动流程立即开始下一轮。' |
no test coverage detected