Skip to content

Commit

Permalink
fix: idle fails to load agent
Browse files Browse the repository at this point in the history
  • Loading branch information
eseidel committed Aug 11, 2024
1 parent 78a3f39 commit 5836843
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/cli/bin/idle_queue.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'dart:io';

import 'package:cli/caches.dart';
import 'package:cli/central_command.dart';
import 'package:cli/cli.dart';
Expand All @@ -16,11 +14,13 @@ Future<void> command(FileSystem fs, Database db, ArgResults argResults) async {
agentSymbol = await db.getAgentSymbol();
}

final agent = await db.getAgent(symbol: agentSymbol);
if (agent == null) {
logger.err('Failed to load agent: ${agentSymbol}');
exit(1);
var agent = await db.getAgent(symbol: agentSymbol);
while (agent == null) {
logger.info('Agent not yet found in database, waiting 1 minute.');
await Future<void>.delayed(const Duration(minutes: 1));
agent = await db.getAgent(symbol: agentSymbol);
}

final systemSymbol = agent.headquarters.system;
var queue = IdleQueue();
void resetQueue() {
Expand Down
1 change: 1 addition & 0 deletions packages/cli/lib/cache/agent_cache.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class AgentCache {
return AgentCache(cached, db);
}
final agent = await getMyAgent(api);
await db.upsertAgent(agent);
return AgentCache(agent, db);
}

Expand Down

0 comments on commit 5836843

Please sign in to comment.