diff --git a/agent/submatview/store.go b/agent/submatview/store.go index 80e9f30b7..58acf5db3 100644 --- a/agent/submatview/store.go +++ b/agent/submatview/store.go @@ -118,8 +118,11 @@ func (s *Store) Get(ctx context.Context, req Request) (Result, error) { } defer s.releaseEntry(key) - ctx, cancel := context.WithTimeout(ctx, info.Timeout) - defer cancel() + if info.Timeout > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, info.Timeout) + defer cancel() + } result, err := materializer.getFromView(ctx, info.MinIndex) // context.DeadlineExceeded is translated to nil to match the timeout diff --git a/agent/submatview/store_test.go b/agent/submatview/store_test.go index ea0e01c2b..9363c772b 100644 --- a/agent/submatview/store_test.go +++ b/agent/submatview/store_test.go @@ -160,7 +160,6 @@ func (r *fakeRequest) CacheInfo() cache.RequestInfo { Key: key, Token: "abcd", Datacenter: "dc1", - Timeout: 4 * time.Second, MinIndex: r.index, } }