(step, timeoutMs = AUTO_RUN_SIGNAL_COMPLETION_TIMEOUT_MS)
| 4501 | } |
| 4502 | |
| 4503 | async function executeStepViaCompletionSignal(step, timeoutMs = AUTO_RUN_SIGNAL_COMPLETION_TIMEOUT_MS) { |
| 4504 | const completionResultPromise = waitForStepComplete(step, timeoutMs).then( |
| 4505 | payload => ({ ok: true, payload }), |
| 4506 | error => ({ ok: false, error }), |
| 4507 | ); |
| 4508 | |
| 4509 | let executeError = null; |
| 4510 | try { |
| 4511 | await executeStep(step, { deferRetryableTransportError: true }); |
| 4512 | } catch (err) { |
| 4513 | executeError = err; |
| 4514 | if (isStopError(err) || !isRetryableContentScriptTransportError(err)) { |
| 4515 | notifyStepError(step, getErrorMessage(err)); |
| 4516 | } |
| 4517 | } |
| 4518 | |
| 4519 | const completionResult = await completionResultPromise; |
| 4520 | if (completionResult.ok) { |
| 4521 | if (executeError) { |
| 4522 | console.warn( |
| 4523 | LOG_PREFIX, |
| 4524 | `[executeStepViaCompletionSignal] step ${step} completed after deferred execute error: ${getErrorMessage(executeError)}` |
| 4525 | ); |
| 4526 | } |
| 4527 | return completionResult.payload; |
| 4528 | } |
| 4529 | |
| 4530 | if (executeError && isRetryableContentScriptTransportError(executeError)) { |
| 4531 | const completionMessage = getErrorMessage(completionResult.error); |
| 4532 | if (/等待超时/.test(completionMessage)) { |
| 4533 | await finalizeDeferredStepExecutionError(step, executeError); |
| 4534 | throw executeError; |
| 4535 | } |
| 4536 | throw completionResult.error; |
| 4537 | } |
| 4538 | |
| 4539 | if (executeError) { |
| 4540 | throw executeError; |
| 4541 | } |
| 4542 | |
| 4543 | throw completionResult.error; |
| 4544 | } |
| 4545 | |
| 4546 | async function waitForRunningStepsToFinish(payload = {}) { |
| 4547 | let currentState = await getState(); |
no test coverage detected