refactor: improve error handling in idle state fuel check to prevent infinite loop
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user