Enhanced automation error handling and monitoring
- Add comprehensive error tracking with consecutive error counts - Implement automatic shutdown after 3 consecutive failures - Reset error counter on successful cycles - Add detailed error logging with stack traces - Improve automation reliability and debugging capability This should prevent silent automation failures and provide better visibility into why automation stops
This commit is contained in:
@@ -134,10 +134,32 @@ class SimpleAutomation {
|
|||||||
if (this.config) {
|
if (this.config) {
|
||||||
// Perform actual analysis using enhanced screenshot API
|
// Perform actual analysis using enhanced screenshot API
|
||||||
await this.performAnalysis();
|
await this.performAnalysis();
|
||||||
|
|
||||||
|
// Reset error counter on successful cycle
|
||||||
|
this.stats.consecutiveErrors = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error in automation cycle:', error);
|
console.error('❌ CRITICAL ERROR in automation cycle:', error);
|
||||||
|
console.error('❌ Stack trace:', error.stack);
|
||||||
|
|
||||||
|
// Increment error counter
|
||||||
|
this.stats.consecutiveErrors = (this.stats.consecutiveErrors || 0) + 1;
|
||||||
|
|
||||||
|
// If too many consecutive errors, stop automation
|
||||||
|
if (this.stats.consecutiveErrors >= 3) {
|
||||||
|
console.error('🚨 TOO MANY ERRORS: Stopping automation after', this.stats.consecutiveErrors, 'consecutive failures');
|
||||||
|
this.isRunning = false;
|
||||||
|
this.stats.status = 'Stopped due to errors';
|
||||||
|
|
||||||
|
if (this.intervalId) {
|
||||||
|
clearInterval(this.intervalId);
|
||||||
|
this.intervalId = null;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`⚠️ Error ${this.stats.consecutiveErrors}/3 - Will retry next cycle`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user