diff --git a/agent/grpc-external/services/resource/watch.go b/agent/grpc-external/services/resource/watch.go index 2fd943a6c9..35ec14513a 100644 --- a/agent/grpc-external/services/resource/watch.go +++ b/agent/grpc-external/services/resource/watch.go @@ -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) }