refactor: improve error handling and retry logic in exploration state for enhanced stability
This commit is contained in:
@@ -26,6 +26,7 @@ export class ExploringState extends BaseState {
|
||||
console.log(`[${this.turtle.id}] Starting exploration`);
|
||||
|
||||
while (!this.cancelled) {
|
||||
try {
|
||||
// Safety checks
|
||||
const fuel = await this.checkFuel();
|
||||
if (fuel !== 'unlimited' && fuel < this.minFuel) {
|
||||
@@ -67,6 +68,18 @@ export class ExploringState extends BaseState {
|
||||
// Exploration movement
|
||||
yield* this._exploreStep();
|
||||
|
||||
} catch (error) {
|
||||
const isTimeout = error.message?.includes('timed out');
|
||||
if (isTimeout) {
|
||||
console.warn(`[${this.turtle.id}] Exploration exec timeout, will retry next iteration`);
|
||||
// Wait longer before retrying after a timeout
|
||||
await this._sleep(3000);
|
||||
} else {
|
||||
// Non-timeout errors still propagate
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
yield;
|
||||
await this._sleep(300);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user