diff --git a/packages/infrastructure/adapters/automation/MockAutomationEngineAdapter.ts b/packages/infrastructure/adapters/automation/MockAutomationEngineAdapter.ts index c905c78d4..1c7b1a0c9 100644 --- a/packages/infrastructure/adapters/automation/MockAutomationEngineAdapter.ts +++ b/packages/infrastructure/adapters/automation/MockAutomationEngineAdapter.ts @@ -64,8 +64,18 @@ export class MockAutomationEngineAdapter implements IAutomationEngine { // Use real workflow automation with IRacingSelectorMap const result = await this.browserAutomation.executeStep(currentStep, config as Record); if (!result.success) { - console.error(`Step ${currentStep.value} (${getStepName(currentStep.value)}) failed:`, result.error); - // Continue anyway for now - in production we might want to pause or retry + const errorMessage = `Step ${currentStep.value} (${getStepName(currentStep.value)}) failed: ${result.error}`; + console.error(errorMessage); + + // Stop automation and mark session as failed + if (this.automationInterval) { + clearInterval(this.automationInterval); + this.automationInterval = null; + } + + session.fail(errorMessage); + await this.sessionRepository.update(session); + return; } } else { // Fallback for adapters without executeStep (e.g., MockBrowserAutomationAdapter)