mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-04-29 12:03:00 +00:00
fix(plugin_manager): prevent permanent ERROR state after update timeout
When execute_update() fails (timeout or unhandled exception), the plugin state was set to ERROR with no recovery path. can_execute() returns False for ERROR state, so the plugin's update() was never called again, leaving it showing stale data indefinitely. Instead, update plugin_last_update so the plugin waits one configured interval before retrying, and keep the state ENABLED so recovery is automatic on the next cycle. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -734,14 +734,18 @@ class PluginManager:
|
|||||||
if self.health_tracker:
|
if self.health_tracker:
|
||||||
self.health_tracker.record_success(plugin_id)
|
self.health_tracker.record_success(plugin_id)
|
||||||
else:
|
else:
|
||||||
# Execution failed (timeout or error)
|
# Execution failed (timeout or error) — update timestamp so the
|
||||||
self.state_manager.set_state(plugin_id, PluginState.ERROR)
|
# plugin waits one full interval before retrying, but keep state
|
||||||
|
# ENABLED so can_execute() returns True and recovery is automatic.
|
||||||
|
self.plugin_last_update[plugin_id] = current_time
|
||||||
|
self.state_manager.set_state(plugin_id, PluginState.ENABLED)
|
||||||
if self.health_tracker:
|
if self.health_tracker:
|
||||||
self.health_tracker.record_failure(plugin_id, Exception("Plugin execution failed"))
|
self.health_tracker.record_failure(plugin_id, Exception("Plugin execution failed"))
|
||||||
except Exception as exc: # pylint: disable=broad-except
|
except Exception as exc: # pylint: disable=broad-except
|
||||||
self.logger.exception("Error updating plugin %s: %s", plugin_id, exc)
|
self.logger.exception("Error updating plugin %s: %s", plugin_id, exc)
|
||||||
self.state_manager.set_state(plugin_id, PluginState.ERROR, error=exc)
|
# Same as the failure path above: stay ENABLED and wait one interval.
|
||||||
# Record failure
|
self.plugin_last_update[plugin_id] = current_time
|
||||||
|
self.state_manager.set_state(plugin_id, PluginState.ENABLED)
|
||||||
if self.health_tracker:
|
if self.health_tracker:
|
||||||
self.health_tracker.record_failure(plugin_id, exc)
|
self.health_tracker.record_failure(plugin_id, exc)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user