refactor: prevent infinite loop in idle state handling by adding retry mechanism
This commit is contained in:
@@ -323,7 +323,17 @@ export class Turtle extends EventEmitter {
|
||||
}
|
||||
} else {
|
||||
console.error(`[Turtle ${this.id}] State error in ${state.name}:`, error.message);
|
||||
this.setState('idle');
|
||||
// Don't transition idle→idle (causes infinite loop)
|
||||
if (state.name !== 'idle') {
|
||||
this.setState('idle');
|
||||
} else {
|
||||
// Already idle and erroring — just wait and retry the idle loop
|
||||
console.log(`[Turtle ${this.id}] Idle loop paused, will retry in 60s`);
|
||||
await new Promise(r => setTimeout(r, 60000));
|
||||
if (this._state === state) {
|
||||
this._runStateLoop(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user