Skip to content

High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.

fix: remove stopped instances from list entirely, don't just mark as stopped

Mario3068321075cc
diff --git a/internal/orchestrator/orchestrator.go b/internal/orchestrator/orchestrator.go
index 7107d0d7..4e3d4eab 100644
--- a/internal/orchestrator/orchestrator.go
+++ b/internal/orchestrator/orchestrator.go
@@ -305,7 +305,6 @@ func (o *Orchestrator) markStopped(id string) {
return
}
- inst.Status = "stopped"
// Release the port back to the allocator
portStr := inst.Port
if portInt, err := strconv.Atoi(portStr); err == nil {
@@ -313,11 +312,16 @@ func (o *Orchestrator) markStopped(id string) {
slog.Debug("released port", "id", id, "port", portStr)
}
- // Delete temporary/ephemeral profiles (auto-generated for instances)
- // These are created with names like "instance-1709275909123456789"
+ // Delete instance from map (remove it entirely, not just mark stopped)
profileName := inst.ProfileName
+ delete(o.instances, id)
o.mu.Unlock()
+ // Log the removal
+ slog.Info("instance stopped and removed", "id", id, "profile", profileName)
+
+ // Delete temporary/ephemeral profiles (auto-generated for instances)
+ // These are created with names like "instance-1709275909123456789"
if strings.HasPrefix(profileName, "instance-") {
// Delete profile directory
profilePath := filepath.Join(o.baseDir, profileName)
diff --git a/internal/orchestrator/orchestrator_test.go b/internal/orchestrator/orchestrator_test.go
index eb03165c..33b37a63 100644
--- a/internal/orchestrator/orchestrator_test.go
+++ b/internal/orchestrator/orchestrator_test.go
@@ -50,6 +50,11 @@ func TestOrchestrator_ListAndStop(t *testing.T) {
inst, _ := o.Launch("p1", "9001", true)
+ // Verify instance is in list before stop
+ if len(o.List()) != 1 {
+ t.Fatalf("expected 1 instance, got %d", len(o.List()))
+ }
+
// Simulate stop
alive = false
err := o.Stop(inst.ID)
@@ -57,9 +62,10 @@ func TestOrchestrator_ListAndStop(t *testing.T) {
t.Fatalf("Stop failed: %v", err)
}
- instStatus := o.List()[0]
- if instStatus.Status != "stopped" {
- t.Errorf("expected status stopped, got %s", instStatus.Status)
+ // Verify instance is removed from list after stop
+ instances := o.List()
+ if len(instances) != 0 {
+ t.Errorf("expected 0 instances after stop, got %d", len(instances))
}
}
@@ -93,8 +99,9 @@ func TestOrchestrator_StopProfile(t *testing.T) {
t.Fatalf("StopProfile failed: %v", err)
}
- inst := o.List()[0]
- if inst.Status != "stopped" {
- t.Errorf("expected stopped, got %s", inst.Status)
+ // Verify instance is removed from list after stop
+ instances := o.List()
+ if len(instances) != 0 {
+ t.Errorf("expected 0 instances after stop, got %d", len(instances))
}
}