Skip to content
This repository was archived by the owner on Jun 3, 2026. It is now read-only.

Commit cb3d0de

Browse files
authored
Fix: fix close bug when run is aborted (#956)
Signed-off-by: Daishan Peng <daishan@acorn.io>
1 parent 31ce029 commit cb3d0de

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

pkg/sdkserver/routes.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,13 @@ func (s *server) execHandler(w http.ResponseWriter, r *http.Request) {
176176

177177
defer func() {
178178
s.runningLock.Lock()
179+
// Need to check if the cancel is still in map. In case when user abort, the channel will be deleted from map and closed already, and closing it again will panic
180+
_, ok := s.running[runID]
181+
if ok {
182+
close(cancel)
183+
}
179184
delete(s.running, runID)
180185
s.runningLock.Unlock()
181-
close(cancel)
182186
}()
183187

184188
// Ensure chat state is not empty.

0 commit comments

Comments
 (0)