mirror of
https://github.com/rancher/steve.git
synced 2025-09-13 13:59:40 +00:00
Fix possible panic on race condition
This commit is contained in:
@@ -175,11 +175,6 @@ func (s *Store) List(apiOp *types.APIRequest, schema *types.APISchema) (types.AP
|
||||
|
||||
func (s *Store) Watch(apiOp *types.APIRequest, schema *types.APISchema, w types.WatchRequest) (chan types.APIEvent, error) {
|
||||
result := make(chan types.APIEvent, 1)
|
||||
go func() {
|
||||
<-apiOp.Context().Done()
|
||||
close(result)
|
||||
}()
|
||||
|
||||
result <- types.APIEvent{
|
||||
Name: "local",
|
||||
ResourceType: "management.cattle.io.clusters",
|
||||
@@ -187,5 +182,10 @@ func (s *Store) Watch(apiOp *types.APIRequest, schema *types.APISchema, w types.
|
||||
Object: s.getLocal(),
|
||||
}
|
||||
|
||||
go func() {
|
||||
<-apiOp.Context().Done()
|
||||
close(result)
|
||||
}()
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user