export const DEFAULT_STEP_TIMEOUT_MS = 60000 export const MAX_QUEUE_TIMEOUT_MS = 2147483647 export function actionQueueTotalTimeout(steps = []) { let total = 0, unlimited = false for (const step of steps) { const timeout = Number(step.timeoutMs ?? DEFAULT_STEP_TIMEOUT_MS) if (!Number.isInteger(timeout) || timeout < 0 || timeout > MAX_QUEUE_TIMEOUT_MS) throw new Error('步骤超时必须是有效的非负整数,0表示不限时') unlimited ||= timeout === 0 total += timeout } if (unlimited) return 0 if (total > MAX_QUEUE_TIMEOUT_MS) throw new Error('队列总超时超出支持范围,请拆分队列或将步骤超时设为0') return total } // Axios timeout=0 disables its timer. Network grace is separate from device execution time. export function actionQueueRequestTimeout(steps) { const total = actionQueueTotalTimeout(steps) return total === 0 ? 0 : Math.min(MAX_QUEUE_TIMEOUT_MS, total + 10000) }