Commit e59ea83a93224db0a81fe1c85cc1ed76e0b91102

Authored by Andrew Kane
1 parent 1e2522c3
Exists in master

Do not allow multi_search timeout to exceed Searchkick.timeout

Showing 1 changed file with 3 additions and 1 deletions   Show diff stats
lib/searchkick/middleware.rb
... ... @@ -9,7 +9,9 @@ module Searchkick
9 9 elsif path.end_with?("/_msearch")
10 10 # assume no concurrent searches for timeout for now
11 11 searches = env[:request_body].count("\n") / 2
12   - env[:request][:timeout] = Searchkick.search_timeout * searches
  12 + # do not allow timeout to exceed Searchkick.timeout
  13 + timeout = [Searchkick.search_timeout * searches, Searchkick.timeout].min
  14 + env[:request][:timeout] = timeout
13 15 end
14 16 @app.call(env)
15 17 end
... ...