Skip to content

Commit dd8ba0d

Browse files
fix(runtime): stop closing s.Events in Stop; use Base.StopWatcher (#3)
The events channel is closed by code.Watcher.Start's `defer close` (the sole sender/closer). Stop also closing it raced that goroutine into a "close of closed channel" panic on shutdown, crashing the agent. Cancel the watcher via Base.StopWatcher() and let its deferred close run once. Requires core with services.Base.StopWatcher (codefly-dev/core#49); the go.mod bump lands with the next core publish. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 8ca36af commit dd8ba0d

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

‎runtime.go‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -379,13 +379,10 @@ func (s *Runtime) Stop(ctx context.Context, req *runtimev0.StopRequest) (*runtim
379379
s.Wool.Warn("error shutting down runner environment", wool.ErrField(err))
380380
}
381381
}
382-
if s.Watcher != nil {
383-
s.Watcher.Pause()
384-
}
385-
if s.Events != nil {
386-
close(s.Events)
387-
s.Events = nil
388-
}
382+
// Cancel the watcher and let its Start goroutine's deferred close of Events
383+
// run exactly once — Stop must not close Events itself, or it races that
384+
// goroutine into a "close of closed channel" panic.
385+
s.Base.StopWatcher()
389386
return s.Base.Runtime.StopResponse()
390387
}
391388

0 commit comments

Comments
 (0)