diff --git a/routing/dht/query.go b/routing/dht/query.go index 293c0ddd9..7a32b45bb 100644 --- a/routing/dht/query.go +++ b/routing/dht/query.go @@ -52,6 +52,9 @@ type queryFunc func(context.Context, peer.ID) (*dhtQueryResult, error) // Run runs the query at hand. pass in a list of peers to use first. func (q *dhtQuery) Run(ctx context.Context, peers []peer.ID) (*dhtQueryResult, error) { + ctx, cancel := context.WithCancel(ctx) + defer cancel() + runner := newQueryRunner(ctx, q) return runner.Run(peers) }