refactor: improve error handling in idle state fuel check to prevent infinite loop

This commit is contained in:
MayaTheShy
2026-02-20 04:38:58 -05:00
parent 5ff1f3e7f0
commit a809bddd46

View File

@@ -14,8 +14,17 @@ export class IdleState extends BaseState {
async *act() {
// Periodic fuel check while idle (no scanning — avoids rotating turtle)
// Errors are caught here so they don't bubble up and trigger
// the _runStateLoop retry mechanism (which would create an
// infinite idle→timeout→idle loop).
while (!this.cancelled) {
try {
await this.checkFuel();
} catch (e) {
// Fuel check failed (likely command timeout) — not critical in idle
// Just wait longer before trying again
await this._sleep(30000);
}
yield;
await this._sleep(10000);
}