Skip to content

Commit 8b5db6e

Browse files
fix: evict token cache in budgetPause, rebuild, and crash paths
Addresses review feedback: evictCreatureTokenCache was only called in stop() but not in budgetPause, rebuild, or failure paths where the creature exits. This ensures the token cache is cleaned up on all exit paths.
1 parent bbdb2f2 commit 8b5db6e

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/host/supervisor.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ export class CreatureSupervisor {
9696
this.status = 'sleeping';
9797
this.sleepReason = 'budget';
9898
this.creature = null;
99+
evictCreatureTokenCache(this.name);
99100
}
100101

101102
async restart(): Promise<void> {
@@ -123,6 +124,7 @@ export class CreatureSupervisor {
123124
this.healthyAt = null;
124125
this.destroyContainer();
125126
this.creature = null;
127+
evictCreatureTokenCache(this.name);
126128
this.currentSHA = getCurrentSHA(this.dir);
127129
this.status = 'starting';
128130
await this.spawnCreature();
@@ -391,6 +393,7 @@ export class CreatureSupervisor {
391393
if (!this.isDockerAvailable()) {
392394
console.log(`[${this.name}] Docker unavailable, stopping (not rolling back)`);
393395
this.status = 'stopped';
396+
evictCreatureTokenCache(this.name);
394397
this.creature = null;
395398
await this.emit({ t: new Date().toISOString(), type: 'host.infra_failure', reason: 'Docker unavailable' });
396399
return;
@@ -436,6 +439,7 @@ export class CreatureSupervisor {
436439
if (this.consecutiveFailures > MAX_CONSECUTIVE_FAILURES) {
437440
console.log(`[${this.name}] ${this.consecutiveFailures} consecutive failures, giving up`);
438441
this.status = 'stopped';
442+
evictCreatureTokenCache(this.name);
439443
this.creature = null;
440444
return;
441445
}

0 commit comments

Comments
 (0)