mirror of https://github.com/status-im/consul.git
resource: handle `ErrWatchClosed` in `WatchList` endpoint (#17289)
This commit is contained in:
parent
879b775459
commit
0a38fc1a2a
|
@ -4,6 +4,8 @@
|
|||
package resource
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
|
@ -51,7 +53,10 @@ func (s *Server) WatchList(req *pbresource.WatchListRequest, stream pbresource.R
|
|||
|
||||
for {
|
||||
event, err := watch.Next(stream.Context())
|
||||
if err != nil {
|
||||
switch {
|
||||
case errors.Is(err, storage.ErrWatchClosed):
|
||||
return status.Error(codes.Aborted, "watch closed by the storage backend (possibly due to snapshot restoration)")
|
||||
case err != nil:
|
||||
return status.Errorf(codes.Internal, "failed next: %v", err)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue